Understanding advanced concepts with data structures
Python offers comprehensive support for data structures, including key tools for storing data and accessing data for processing and retrieving. In Chapter 4, Python Libraries for Advanced Programming, we discussed the data structure objects that are available in Python. In this section, we will cover a number of advanced concepts such as a dictionary within a dictionary and how to use comprehension with a data structure. We will start by embedding a dictionary inside a dictionary.
Embedding a dictionary inside a dictionary
A dictionary in a dictionary or a nested dictionary is the process of putting a dictionary inside another dictionary. A nested dictionary is useful in many real-world examples, particularly when you are processing and transforming data from one format into the other.
Figure 6.1 shows a nested dictionary. The root dictionary has two dictionaries against key 1
and key 3
. The dictionary against key 1
has...