I am trying to solve a problem where I'm given an array, such as [0, 0, 1, 1, 2, 2, 6, 6, 9, 10, 10] where all numbers are duplicated twice, excluding one number, and I need to return the number that is not duplicated.
I am trying to do it like this:
def findNumber(self, nums):
    if (len(nums) == 1):
        return nums[0]
    nums_copy = nums[:]
    for i in nums:
        nums_copy.remove(i)
        if i not in nums:
            return i
        else:
            nums_copy.remove(i)
However when it reaches the else statement, there is the following error:
ValueError: list.remove(x): x not in list
This is occurring when i is in nums_copy, so I do not understand why this error occurs in this situation?
 
     
     
     
     
     
     
     
     
     
    