September 2013
Intermediate to advanced
350 pages
9h 38m
English
We said in Lists Are Heterogeneous, that lists can contain any type of data. That means that they can contain other lists. A list whose items are lists is called a nested list. For example, the following nested list describes life expectancies in different countries:
| | >>> life = [['Canada', 76.5], ['United States', 75.5], ['Mexico', 72.0]] |
Here is the memory model that results from execution of that assignment statement:

Notice that each item in the outer list is itself a list of two items. We use the standard indexing notation to access the items in the outer list: ...
Read now
Unlock full access