I create a 3×3 grid for a small LED matrix simulation with grid = [[0] * 3] * 3. Setting one cell with grid[0][1] = 1 gives [[0, 1, 0], [0, 1, 0], [0, 1, 0]]: the whole column changes. A second surprise in the same script: after backup = grid, changes to grid also appear in backup.
Why do both happen, and what is the correct way to build a 2D list and to make an independent copy of one?




