Can someone help me understand why I'm throwing this error?
"Oops, try again. Your remove_duplicates modifies the list that was passed to it. [4, 5, 5, 4] was modified to [5, 4]. Perhaps you should make a copy first!"
Per my code the first thing I did is make a copy of the list and the only modification was to the new list.
lst = [4,5,5,4] def remove_duplicates(n): lst2 = n # copies input into new list for i in lst2: # loop through list if lst2.count(i) > 1: # check if duplicated lst2.remove(i) # if dup, remove from list return lst2 print remove_duplicates(lst)