Can anyone explain the logic behind this code?
def move(list1,list2):
for num in list1:
list2.append(num)
list1.remove(num)
list1=[1,2,3,4,5]
list2=[10]
move(list1,list2)
print(list1,list2)
I have been trying to figure out why the output is
[2, 4] [10, 1, 3, 5]
but not
[] [10,1,2,3,4,5]
Shouldn't all the num in list1 move to list2? I'm still a beginner in python.