Remove duplicates



I'm struggling with the Purify exercise. I'm not sure if this is even a decent way of doing this, but this is what I have so far:

 def remove_duplicates(x):
    new_list = []
    for items in x:
        while x.count(items) >1:
    return new_list

It gives me the following error: Oops, try again. remove_duplicates([4,5,5,4]) resulted in an error:

And that's it. It's not specifying the error. Any help would be appreciated!

Link to exercise


This line is creating an infinite loop.


Ah yes, of course. Brain fart I guess. Thanks for the heads up!


What if you loop over the original list, and if not found in the temporary list, append it?


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