0Pricing
Python Academy · Lesson

Nested Lists and Iteration

Work with nested lists and iterate efficiently with for loops.

Introduction

Lists can contain other lists, creating multi-dimensional structures. Mastering nested iteration is key for grids and matrices.

Nested List Structure

matrix = [[1,2,3],[4,5,6],[7,8,9]] is a 3x3 grid. matrix[1][2] accesses row 1, column 2 — which is 6.
matrix = [[1,2,3],[4,5,6],[7,8,9]]
print(matrix[1][2])

All lessons in this course

  1. Creating and Accessing Lists
  2. Modifying Lists
  3. Tuples and Immutability
  4. Nested Lists and Iteration
← Back to Python Academy