I'm trying to edit a value in a 2D array.
Just the value at [0][0]
but when I edit it, it propagates to all the values at [x][0]
and I don't understand why.
I then copied the exact line from an example that I found online and it works but I don't understand what the difference is.
I simplified both examples and they still don't have the same solutions. This doesn't add up.
counter= 3*[4*[0]]
counter[0][3] = 7
print(counter)
T = [[0, 0, 0, 0], [0, 0,0,0], [0, 0, 0, 0]]
T[0][3] = 7
print(T)
the top print statement gives:
[[0, 0, 0, 7], [0, 0, 0, 7], [0, 0, 0, 7]]
the bottom gives:
[[0, 0, 0, 7], [0, 0, 0, 0], [0, 0, 0, 0]]
but they should be the same.