I am confused about a really simple problem with list built-in function, pop.
The code is simple as it can be.
L=[1,2]
for i in L:
print i
L.pop(0)
and it gives
1
I tried it with a longer list
L=[1,2,3,4,5,6]
for i in L:
print i
L.pop(0)
and it gave me
1
3
5
So, back to the first code, what I thought was from the line 'for i in L', the for loop will run for '1' first, so it will print i and then L.pop(0) will remove '1' from L. Then, there will be another loop for '2 in L', which will print 2, making L empty list. However, it only returned 1, and 1,3,5 in case of second case. What am I missing here?