+ 1
What are the advantages / disadvantages of using lists or tuples? And dictionaries?
3 Antworten
+ 8
Tuples are set in their ordering and values.
Lists are numerically keyed and can be sorted and have values removed or added.
Dictionaries can have whatever key you would like and similarly to lists can be adjusted in values and size.
+ 4
A major difference between Lists and the rest that you 're asking is that Lists are mutable. Tuples and Dictionaries are immutable so their values are fixed. There can be no precise explanation to your question since the real question is what do you want your program to do? If you want to collect values and store them somewhere then Lists is the solution you are searching for, since they can be mutated. If you want to get values from something like a database then Tuples or Dictionaries might be a good solution. Dictionaries give you the perk of a key usage also. So it all depends on what you want to achieve. I'm not sure if this helps.
+ 2
Tuples are fastest data types in Python