+ 1
When to use tuples vs lists?
4 Respuestas
+ 8
Tuples are fixed size in nature whereas lists are dynamic.
In other words, a tuple is immutable whereas a list is mutable.
You can't add elements to a tuple. Tuples have no append or extend method.
You can't remove elements from a tuple. Tuples have no remove or pop method.
You can find elements in a tuple, since this doesn’t change the tuple.
You can also use the in operator to check if an element exists in the tuple.
+ 2
Well, StackOverflow gives a pretty good explanation http://stackoverflow.com/a/1708538
+ 1
I think that tuples can help in case you want to make lists as dictionary keys. List cant be keys, but you can transform them in tuples and use as keys
0
tuples are static , u must use them when setting the resolution of your game that's made with pygame. lists are dynamic and can be used to make an inventory in an mmorpg ( just an example)