What
for x in a:
Really does is that it uses an internal counter, so it will return a[0], a[1], a[2]...
What happens with your code is that removing an item changes the position where the loop index should point, so:
First loop, index == 0
, you remove a[0]
, which is 0. Second loop, index is 1, but now, a is [1..49], and a[1]
is 2.
And so on.