0
key=[[1,2,3,4],[5,6],[7,8,9,10]]
x=key
i=0
print(1,key)
while i<4:
x[0][i]=x[2][i]
i+=1
print(2,x)
print(3,key) #key era para se manter o mesmo valor, mas quando altera x, key está se alterando também,
I simply want to assign the value of array key
for x
, but every time I change x
, key
also changes itself
In the terminal the print
sai:
1 [[1, 2, 3, 4], [5, 6], [7, 8, 9, 10]]
2 [[7, 8, 9, 10], [5, 6], [7, 8, 9, 10]]
3 [[7, 8, 9, 10], [5, 6], [7, 8, 9, 10]]