Ad
  • Custom User Avatar

    The problem is you are modifying aat the same time you are iterating on it. This is something you should avoid since it can lead to weird / unexpected results. One solution could be to iterate over a copy of a (while still modifying a) or to work with indices Look at the other submitted solutions to see other ideas of code working here.

    For example, if you add print(item) at the entry of you first loop, you will see that on fixed test #6 the 2 is never parsed.