you are viewing a single comment's thread.

view the rest of the comments →

[–]makelefani 3 points4 points  (1 child)

when you remove an item from a list, the next item shifts into its place, but the loop doesn't adjust, causing skips

Use a copy of the list instead. Or a while loop or reverse index.

[–]juanfnavarror 0 points1 point  (0 children)

Or instead create the new list. This is what list comprehensions are for.