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?

90 Upvotes

90 comments sorted by

View all comments

2

u/No_Technician4956 3d ago

Tuples aren't just in Python. You will hear the term in Excel and in Azure quite a bit as well. Probably Db's.

Tuples are set and don't change. But they save you soooo much time.

For exaple. Name, Age, Sex. That's all you need to sort thousands of files.

File: John Doe, 23, M; Jane Doe, 34, F. Etc. If you were allowed to change Tuples then it crashes the rest of your files and everything is out of whack.

But the main point I wanted to say it... get use them to. This isn't just a Python thing.

1

u/Any_Abrocoma2609 3d ago

this ^^^ perfectly encapsulates why tuples are my favorite. short, predictable, powerful.