I have a 2d list of the form [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]] and I want to change the list value at only a single index for example at (0,0) to 0 [[0, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]].
I have a function that take the row index, col index and value and a 2d list called "picture " (plus other non-related arguments). and I try to change the picture in the row and column index to the value like this:
def create_picture(row, col, val, constraints_set, picture, possibilities, path):
if (row, col, val) not in path:
picture[row][col] = val
path.add((row, col, val))
But for example for row=0, col=0 and val=0 (which I checked) and picture [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]] I get:
[[0, -1, -1, -1], [0, -1, -1, -1], [0, -1, -1, -1]]
only after a single run.
When I run it manually using:
picture = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]
picture[0][0] = 0
print(picture)
I do get [[0, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]
I hope you can help me, thanks.