$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #114

What is the correct fix?

rows = [r for r in rows if r.ok]
for i, r in enumerate(rows):
    if not r.keep:
        del rows[i]
  1. Rebuild it: [r for r in rows if r.keep]
  2. Rebuild it: [r for r in rows if not r.keep]
  3. Iterate backwards over the row indexes
  4. Change del rows[i] to rows.pop()
Deleting during enumerate shifts later items and skips them; build a new list instead.
Play Problem Solving ▸