I have made a 5x5 python list (A) and a numpy array (B). But when I set A[0][0]=1 for the python 2D list and set B[0][0]=1 for the numpy array, I get these results (I was expecting to get results like I got for the numpy array, but why is it converting all the first elements of all the rows into 1 for the python list?):
A = [[0] * 5] * 5
A[0][0] = 1
print(A)
B = np.zeros((5, 5))
B[0][0] = 1
print(B)
results:
A= [[1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]]
B=
[[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.]]