Which fix removes the bug?
for item in items:
if item.expired:
items.remove(item)
- Iterate over a copy
- Break after removing
- Reverse the list first
- Use a while loop
Mutating the list you are iterating shifts positions and silently skips elements.
Play Problem Solving ▸