What is the difference between list, dictionary and tuple in Python exactly?
Asked
Active
Viewed 7.2k times
28
-
Similar to http://stackoverflow.com/questions/3489071/in-python-when-to-use-a-dictionary-list-or-set: In Python, when to use a Dictionary, List or Set? – Mark Byers Sep 06 '10 at 08:00
-
http://docs.python.org/py3k/tutorial/datastructures.html – Humphrey Bogart Sep 06 '10 at 09:52
1 Answers
53
A list can store a sequence of objects in a certain order such that you can index into the list, or iterate over the list. List is a mutable type meaning that lists can be modified after they have been created.
A tuple is similar to a list except it is immutable. There is also a semantic difference between a list and a tuple. To quote Nikow's answer:
Tuples have structure, lists have order.
A dictionary is a key-value store. It is not ordered and it requires that the keys are hashable. It is fast for lookups by key.

Community
- 1
- 1

Mark Byers
- 811,555
- 193
- 1,581
- 1,452