r/learnpython • • Mar 27 '23

Actually using a tuple

Can someone, please, give me a "real-world" example on the use of a tuple? I'm learning through w3schools. The idea of a tuple sort of makes sense, but I have no idea how it would/could be applied.

147 Upvotes

64 comments sorted by

View all comments

2

u/[deleted] Mar 27 '23

Dropdown form values for a menu option. For example you might have a list of tuples for type of car engine

Engine_type = (1, "EV"), (2, "ICE")

I use this pattern all the time in Pythons Flask framework.