Using python, it is possible to remove elements from a list that you are currently looping on.
Why is it possible ? Why is removing an element from the list while looping on it not causing a problem (breaking indexes, etc. ?) ?
Example code:
ml = ["1","2","3","4","5","6","7","8","9","10"]
for m in ml:
if m == "5":
ml.remove("9")
ml.remove("1")
print(ml)
Output with Python 3.8.3:
['2', '3', '4', '5', '6', '7', '8', '10']
Edit: I am not asking how to remove an element from a list, I am asking why there is no consequence during the rest of the iteration
Edit: Seems like people do not actually read everything during triage...
Better answer is here: Strange result when removing item from a list while iterating over it
Again, I was not asking "How to remove from list", but why is it not causing problems (or at least, in my code example).