r/learnpython • u/Immediate_Pin_8449 • Oct 12 '26
Tuples..I don’t get it
Hi crew, I’m a Python newbie and I just learned about the concept of tuples.
We can’t change them.if we want to store we have to start at the index we want + 1.
I just don’t get it. Why wouldn’t we just use lists? When would we ever need this?
100
Upvotes
View all comments
Show parent comment
4
u/HommeMusical Oct 13 '26
Good energy, but this isn't really right.
The fact that you can use tuples in dictionaries isn't the main reason they exist, or a super-common use for them (it's not uncommon).
The reason they exist is they are a very resource light way to glue together specific items in a specific order that cannot be changed.
For example, if you needed to return a string and an integer together from a function, you'd just do this:
This creates a tuple with two elements and returns it, and this is probably the most common visible use of a tuple.
In fact, every time you call a function, behind the scenes it creates a tuple and a dict to pass the arguments to that function.
So tuples are just a simple little box with a fixed number of fixed elements in it - the simplest collection. Other collections, like
dictandlist, have a lot more "stuff" associated with them and thus are bigger and a bit slower.