I have the below small code in Python where I am changing the value of list_one by using pop() function but I am not doing any changes in list_two. on printing list_one and list_two they both print the same results as mentioned below.
arr = [1,2,3,4,5]
list_one = arr
list_two = arr
list_one.pop(0)
print(list_one)
print(list_two)
Output:
[2, 3, 4, 5]
[2, 3, 4, 5]
Can someone please help me understand why list_two is also changing even though I did not make any changes into it. I understand that both list_one and list_two refer to 'arr' but I was expecting list_one to create new reference to the modified list, and was expecting list_two to maintain existing reference to 'arr'.
please help me out.