December 2017
Beginner to intermediate
410 pages
12h 45m
English
Python dictionaries (dict) are efficient ways of storing information. Just as an actual dictionary stores a word and its corresponding definition, so a Python dict stores some key and a corresponding value. Using dictionaries can make your code more readable because a label is assigned to each value in the dictionary. Contrast this with list objects, which are unlabeled. Dictionaries are created by using a set of curly brackets, {}.
my_dict = {}
print(my_dict)
print(type(my_dict))
When we have a dict, we can add values to it by using square brackets, []. We put the key inside these square brackets. Usually, it is some string, but it can actually be any immutable type (e.g., a Python tuple, which is the immutable ...