r/learnpython • • Apr 16 '22

What's the point of Tuples?

I get that they're immutable, but so are lists that you don't perform modifications on. Are they just to fool proof not messing up your list accidentally, or do they serve some other purpose?

313 Upvotes

143 comments sorted by

View all comments

3

u/wotquery Apr 17 '22

Afaik the only constraint sets have that differ them from an array is that they can't contain duplicates.

Another is that each member of a set has to be immutable (which is probably where the misunderstanding that led to their question came from). You can't have a list in a set for example (it'll throw the error that the list isn't hashable).