Dictionaries

3.8. Dictionaries#

The last fundamental built-in Python type is the dictionary (dict). Like lists and tuples, a dictionary contains any number of elements. However, lists and tuples store elements in a sequential way that we address using indexes or slices, whereas dictionaries store elements non-sequentially using keys. This section introduces how to create, read and modify dictionaries.

Tip

If you come from Matlab, Python’s dict fulfils the same role as Matlab’s struct.