I was working on Colab and I had to make csv to 2d array.
But I had never used python before (I was C user) so I'm not skilled at python list.
real = [1, 2]
copy = [[0] * 2] * 4
print(copy)
for j in range(1):
for i in range(2):
copy[i][j] = real[i]
print(copy)
I expected
[[0, 0], [0, 0], [0, 0], [0, 0]]
[[1, 0], [0, 0], [0, 0], [0, 0]]
[[1, 0], [2, 0], [0, 0], [0, 0]]
but it works like this
[[0, 0], [0, 0], [0, 0], [0, 0]]
[[1, 0], [1, 0], [1, 0], [1, 0]]
[[2, 0], [2, 0], [2, 0], [2, 0]]
Please help me...