Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It is actually much simpler: you change 'n' as well:

    while i < n:
      if shouldDelete(iterable[i]):
        del iterable[i]; n -= 1
      else:
        i += 1



Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: