Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction to nested lists
5. Multidimensional nested lists
Iterating over nested lists
Modifying nested lists
Working with multiple lists
Summary

Instruction

Well done! The examples in the previous exercises were based on two-dimensional nested lists – i.e., lists within lists. They are the most popular kind of nested list, but you can also create nested lists with more dimensions. Take a look:

three_dimensions = [
  [[1, 2], [3, 4]],
  [[5, 6], [7, 8]]
]

The example above presents three-dimensional nested lists: lists within lists within lists. To access a given element, you will now need three pairs of square brackets:

three_dimensions[0][0][1] # returns 2

Even though Python does not limit the number of list dimensions, nested lists with more than three dimensions are rarely used. In this course, we're going to focus on 2D lists.

Exercise

Click Next exercise to continue.