This code block is giving me unexpected results, and I am not sure why:
grid = [[0] * cols] * rows
grid[0][1] = 1
print(grid) # [[0, 1], [0, 1]]
I expected the grid to be [[0, 1], [0, 0]], not [[0, 1], [0, 1]]. What causes grid[1][1] to be mutated as well?
Thank you.