append method in Python.. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

append method in Python..

in the code.. list1=[1,2,3,4] list2=list1 list1.append(5) print(list2) OUTPUT: [1,2,3,4,5] why the changes made in list1 is reflected to list2 ? (is it like in c++ we work with addresses ?)

18th Dec 2017, 5:23 PM
Aaditya Deshpande
Aaditya Deshpande - avatar
2 Answers
+ 1
because list2 ist the same as list1 just with another name
18th Dec 2017, 5:11 PM
Jeremy
Jeremy - avatar
+ 1
If u made changes in the list1 it also make changes to list 2
21st Dec 2017, 8:09 AM
Roby Selvaraj
Roby Selvaraj - avatar