I have a piece of code that should be updating a single item in a list but instead updates the entire list.
Here is the code
a = [
[(0, 0), (3, 4)]
]
board = [[0] * 5] * 5
for solution in a:
for _x, _y in solution:
board[_x][_y] = 1
print(board)
Expected output:
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 1
0 0 0 0 0
Actual output:
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1
1 0 0 0 1