Can anyone explain to me exactly why this Python script produces this output?
>>> a = range(0,50)
>>> for x in a:
... a.remove(x)
...
>>> a
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]
This seems strange to me, because the script only removes every second entry. I would think that the loop would iteratively remove all the items in the list.