+ 1
Why output come like this
A=[1,2,3,4] B=A A[0]=0 B[1]=9 print(B) print(A) Output >> [0, 9, 3, 4] [0, 9, 3, 4] Why not [1, 9, 3, 4] [0, 2, 3, 4]
4 Answers
+ 2
About the topic references, see here for more details:
https://code.sololearn.com/c89ejW97QsTN/?ref=app
+ 1
I doesn't change second element of A, and first element of B, But in output both are changedđ€
+ 1
to copy a list
B=A[:]