My code works just fine and I get the correct output but the code academy part gives me the error "Oops, try again. Your remove_duplicates modifies the list that was passed to it. [4, 5, 5, 4] was modified to [4, 4, 5, 5]. Perhaps you should make a copy first!" even though when I print the result of the my function it gives me [4,5]
I realize my code isn't the most streamlined, but it does work so I am frustrated that code academy feels otherwise.
def remove_duplicates(nums): nums.sort() singles= x=len(nums) i=1 for num in nums: if num == nums[x-1]: if num not in singles: singles.append(num) elif num != nums[i]: if num not in singles: singles.append(num) i=i+1 print singles return singles remove_duplicates([4,5,5,4]).