Remove_duplicates: rejected results


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):
    for i in lst:
        if i not in lst2:
    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]

Do somebody know, where's the problem?


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:


Ohh. Thank you very much. :slight_smile:


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