When I create these 2 arrays with different techniques but effectively the same idea, the first one reacts way differently when I attempt to edit a SINGLE row and not the entire thing. When debugging, I see it editing every column at once rather than a single row column at once. I was following this technique. The code I am comparing is as follows:
arr=[[0]*8]*8
for i in range(len(arr[0])):
arr[0][i]=1
print(arr)
Output:
[[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]
arr=[[0 for j in range(8)] for i in range(8)]
for i in range(len(arr[0])):
arr[0][i]=1
print(arr)
Output:
[[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]