# Remove_duplicates: rejected results

#1

Hi, I'm stucked in this exercise.
I tested it and in my opinion it works well, but there's still this error message (for me it doesn't make any sense), so I think, that I probably misunderstood the task:

Oops, try again. remove_duplicates([6, 8, 122, 2, 18]) returned [] instead of [8, 122, 18, 2, 6]

Here's my code:

``````def remove_duplicates(lst):
lst2=[]
result=[]
for i in lst:
if i not in lst2:
lst2.append(i)
else:
result.append(i)
return result

print remove_duplicates([1, 2, 3, 2, 4, 3, 5, 1, 6, 2, 2, 2, ])``````

...and the (for me correct) result:

[2, 3, 1, 2, 2, 2]
None

Do somebody know, where's the problem?

#2

The result you are returning is the opposite of what should be returned. Perhaps only use one list. `result` is a good name.

``````result = []
for i in lst:
if i not in result:
result.append(i)``````

#3

Ohh. Thank you very much.

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.