-2

so I am working on this program and I am trying to remove duplicates from an array and I wanna leave the inner loop and go back to the outer loop after every iteration but I don't want the inner loop to start over because now everytime I break out of the inner loop the next iteration the inner loop starts all over again so num is always 1

 def removeDuplicates(self, nums: List[int]) -> int:
    for i in range(len(nums)-1):
        curr = nums[i+1]
        for num in nums:
            if num == curr:
                print('removed ' , num)
            break

Barmar
  • 741,623
  • 53
  • 500
  • 612

1 Answers1

0

Simply use a set then

nums = list(set(nums))
vultkayn
  • 189
  • 1
  • 8