Nov-16-2019, 04:52 PM
I have just started using python and encountered this problem. I made list2 a copy of list1. When I remove the last element ("b") in list2 using list2.pop(), the same thing happens to list1 at the same time (which was not intended). Are list1 and list2 somehow 'entangled'?? What should I do if I want to make such changes to one of the lists only?
I know this might be a silly question but still please help :)
I know this might be a silly question but still please help :)
list1 = ["a","b"] list2 = list1 print("list1 = ", list1) list2.pop() print("list1 = ", list1)