Ad
  • Default User Avatar

    Helps to visualise this using pythontutor.com - the issue is that you are reversing the list in order to remove the later occurrences, but that doesn't handle the fact that when you remove items, they are removed from the beginning of your list and thus the items in your working list shift.
    For example:
    After you reverse your list, index 0 is 30, index 1 is 33. Upon evaluating index 0 (integer 30), it removes all but the last occurrence of 30, which actually removes the first item in your list.
    In the next loop, index 0 is 33, but the loop is now looking at index 1, so 33 gets skipped.