0

can any one explain output of this code

list1=[1, 3,4,5] list2=list1 list2[0]=5 print(list1[0])

21st Feb 2020, 6:05 PM
shivam patidar
shivam patidar - avatar
4 Réponses
+ 4
The output must be 5 because here the reference of list1 is assigned to list2. So there is a single list pointed by two objects. So the change in one means it will be reflected on the other as well.
21st Feb 2020, 6:37 PM
Avinesh
Avinesh - avatar
+ 1
Not equal - they are the same list. Just like your mom is also your grandmother's daughter. Two words, one thing.
21st Feb 2020, 7:52 PM
HonFu
HonFu - avatar
0
ouput is 5
21st Feb 2020, 6:31 PM
shivam patidar
shivam patidar - avatar
21st Feb 2020, 6:33 PM
shivam patidar
shivam patidar - avatar