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 .

Lecture Prep

Watch:
  1. Nested Lists (7 minutes) Also called multidimensional lists
  2. Nested Slicing (6 minutes) Slicing a nested list makes a copy of the top-level list only; this is called a shallow copy.
  3. Defining Functions for Tables, part 1 (9 minutes) Some examples of functions that do not modify the nested list given as argument ( immut.py )
  4. Defining Functions for Tables, part 2 (8 minutes) Some examples of functions that modify the nested list given as argument ( mut.py )

AND read 11.1 - 11.5 on dictionaries


Lecture materials

Slides: individual slides for viewing , 6-up layout for printing

Examples: table.py (skeleton), table.py

Questions and Answers: check the answers after you try them on your own!

Link to Lecture Recording