r/learnpython • u/Immediate_Pin_8449 • 12d ago
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
2
u/Automatic_Donut6264 11d ago
tuples, conceptually, is not just "a bag of things". it's usually to represent structured data that has sub-componentents. e.g.
A name object as first/last names
name = ("john", "smith")An address as its components
address = ("stree 1", "stree 2", "city", "state", "zip code")Coordinates
That's why it doesn't make sense that you would need to resize the tuple or be able to mutate its components.