+ 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]

2nd Aug 2020, 1:19 PM
yasin ashraf
yasin ashraf - avatar
4 ответов
+ 2
About the topic references, see here for more details: https://code.sololearn.com/c89ejW97QsTN/?ref=app
2nd Aug 2020, 4:00 PM
HonFu
HonFu - avatar
+ 1
I doesn't change second element of A, and first element of B, But in output both are changed🤔
2nd Aug 2020, 1:25 PM
yasin ashraf
yasin ashraf - avatar
+ 1
to copy a list B=A[:]
2nd Aug 2020, 1:26 PM
hamit