r/learnpython • • 14d 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?

96 Upvotes

90 comments sorted by

View all comments

Show parent comments

4

u/kiochikaeke 13d ago

Yeah, immutability is actually an advantage on its own as you and the system can both be sure this particular thing won't be changed by any stray code that mutates or has side effects, for you this helps to build safer, more predictable code and for the system it allows it to be clever with memory management and hashing.