I am trying to execute this python code below, and i see the data of the 2-d array "grid" , is changing after the fourth print statement. I don't understand why it is changing . can anybody help me please?
print(grid)
for i in range(len(grid)):
grid[i]=list(grid[i])
print(grid)
set1=grid
print(grid)
for i in range(len(set1)):
for j in range(len(set1[i])):
set1[i][j]='O'
print(grid)
debug output:
['.......', '...O...', '....O..', '.......', 'OO.....', 'OO.....']
[['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'O', '.', '.', '.'], ['.', '.', '.', '.', 'O', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['O', 'O', '.', '.', '.', '.', '.'], ['O', 'O', '.', '.', '.', '.', '.']]
[['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'O', '.', '.', '.'], ['.', '.', '.', '.', 'O', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['O', 'O', '.', '.', '.', '.', '.'], ['O', 'O', '.', '.', '.', '.', '.']]
[['O', 'O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', 'O', 'O']]