What is the correct fix?
grid = [[0] * 3] * 3 grid[0][0] = 5 print(grid[1][0])
- Build rows:
[[0] * 3 for _ in range(3)] - Build rows:
[[0] for _ in range(3) * 3] - Change
grid[0][0] = 5to append a row - Wrap the outer list in
list(grid)first
* 3 repeats the SAME inner list three times, so one write appears in every row.