I wrote the following code:
grid = [[0,0,0,0,0],[0,0,0,0,0]]
grid2 = [[1,1,1,1,1],[1,1,1,1,1]]
grid2 = grid
grid2[0][0] = 5
print(grid2)
print(grid)
And this is the output:
[[5, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
[[5, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
Why does the variable grid
also get 5
in its output? These are two separate variables and I'm only changing one? Is there anyway to not have them synced?