Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    To OP: Please mark your post as having spoiler content next time.

  • Custom User Avatar

    That's because you have a subtle error in your logic: your code will return in the first iteration of the loop. Your code translates to something similar to: if this, return this, else return that (first iteration). By adjusting your overall structure (which in this case, is just modifying number of tabs/spaces for some line(s)), your code will pass.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Thanks for your reply! I didn't have full understanding of how loops work. It's great that here I can find help from more experienced users

  • Default User Avatar

    I was doing something similar and getting the same error. Then added some print functions to try and see what was going on and realised it wasn't doing as many loops as expected. Then realised this is because you are deleting items from the list being iterated, so when it completes a loop where it deletes an item, the list shortens and the next item in the list goes to the current index and it moves to the next iteration if there is one.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution