My code to the question "Write a function remove_duplicates that takes in a list and removes elements of the list that are the same (in the form of a new list)" returns an empty list, that is, []
, instead of a list with no duplicates.
I cannot seem to understand why?
def remove_duplicates(sequence):
k = []
for x in sequence:
for i in k:
if x != i:
k.append(x)
else:
k = k
return k