DICTIONARIES
Python has a key/value structure called a dictionary (dict) that is a hash table. A dictionary (and hash tables in general) can retrieve the value of a key in constant time, regardless of the number of entries in the dictionary (and the same is true for sets). You can think of a set as essentially just the keys (not the values) of a dict implementation.
The contents of dict can be written as a series of key:value pairs, as shown here:
dict1 = {key1:value1, key2:value2, ... }
The “empty dict” is just an empty pair of curly braces {}.
Creating a Dictionary
A dictionary (or hash table) contains of colon-separated key/value bindings inside a pair of curly braces:
dict1 = {}
dict1 = {'x' : 1, 'y' : 2}
The preceding code snippet defines dict1 as an empty dictionary, and then adds two key/value bindings.
Displaying the Contents of a Dictionary
You can display the contents of dict1 with the following code:
>>> dict1 = {'x':1...