practicepython.in
python exercises
171 exercises

Daily #3 · 1 October 2026

One change, two rows Medium

What does this print?

grid = [[0] * 3] * 2
grid[0][0] = 1
print(grid)
  1. Araises IndexError
  2. B[[1, 1, 1], [0, 0, 0]]
  3. C[[1, 0, 0], [0, 0, 0]]
  4. D[[1, 0, 0], [1, 0, 0]]
Show the answer

D: [[1, 0, 0], [1, 0, 0]]

Why: * 2 copies the reference to the inner list, so both rows are the same list. Change one and you have changed both. [[0] * 3 for _ in range(2)] builds two separate rows.

Play today’s puzzle →