Ad
  • Custom User Avatar

    I had not thought to use a copy of list. Thank you for such valuable advice.

  • 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.

  • Custom User Avatar

    I did the same thing

  • Custom User Avatar

    Can anyonw tell me why my code only works when i have both for loops, and not just the first one (for item in a:)?