A list can contain anything, even other lists. When we have a list of lists, we can call it a nested list.
The dictionary is a built-in type in Python, called dict
. A dictionary is a collection like a list, but unlike a list whose values are identified positionally using integer indices, the values in a dictionary are identified by keys, which can be any immutable type (e.g., string
) and not just int
.
AND read 11.1 - 11.5 on dictionaries
Slides: individual slides for viewing, 6-up layout for printing
Examples:
table.py (skeleton),
table.py,
list_2d_print.py (another version),
list_2d_transpose.py
To download the above .py files, right-click (Windows) or command-click (Macs) on the filename and then select "Save link as".
This way you choose where the files will be saved, instead of having your computer save to the default folder (from which you will later have to move your files for organization).
Answers to the questions on slides 30 and 32: See the lecture slides file above for the questions. After solving the problems yourself, you can check your answers here.