I've noticed that in Python 3.6 when removing items from a list while looping through a list, as in the code below, the loop will be exited after the first time that an item is removed. Any ideas why this is? Does this always happen when you modify the iterible that you're looping over?
x = list(np.arange(5))
for i in x:
if (i == 2) | (i == 3):
x.remove(i)
x
[0, 1, 3, 4]