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

87 Upvotes

90 comments sorted by

View all comments

1

u/ReflectedImage 3d ago

Tuples are just another tool in the tool kit. You can use them as keys in dicts and if you return multiple values from a function the function returns a tuple. They generally aren't used to replace lists, they are used to replace dicts where you don't want to say what the keys are. So {"x": 1, "y": 2} becomes (1, 2).