Python 3 Console Skills – 2 Dictionaries
Dictionaries are a type of data structure in Python that store key: value pairs. When you look up word in an English dictionary, you would see that word’s definition. In a Python dictionary, looking up the key returns the associated value.
For example:
| Animal | Sound |
| dog | a barker |
| cat | a meower |
| bird | a tweeter |
We could do this in a dictionary:
sounds = {‘dog’: ‘a barker’, ‘cat’: ‘a meower’, ‘bird’: ‘tweeter’}
print(sounds)
{‘dog’: ‘a barker’, ‘cat’: ‘a meower’, ‘bird’: ‘tweeter’}
