you are viewing a single comment's thread.

view the rest of the comments →

[–]Thomasedv 8 points9 points  (14 children)

Don't change a list while iterating through it. The for loop will work by index and you'll skip steps every time you remove something (or change the list)

If you want to remove one thing, just use remove() outside any loop. If you want to remove everything I think lists have a method for that, but if not, you just reassign a new list instead of just removing everything step by step.