Remove_duplicates error


def remove_duplicates(llist):
newlist = []
templist = llist[:]
for i in templist:
if i not in newlist:

return newlist

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

Replace this line with your code.


There is no need to remove elements from the main list, simply iterate over it. The new list will contain only unique characters.


You dont need this,


also you don't need tempelist!


Thank You very much for your reply.It was very helpful.


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