$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · easy · #159

Which fix removes the bug?

for item in items:
    if item.expired:
        items.remove(item)
  1. Iterate over a copy
  2. Break after removing
  3. Reverse the list first
  4. Use a while loop
Mutating the list you are iterating shifts positions and silently skips elements.
Play Problem Solving ▸