Remove_duplicates code don't work


#1



Hi,
while working on remove_duplicates i tried this code but i got error that my list returns empty
my code:

def remove_duplicates(x):
    y=[]
    for i in x:
        if x.count(i) <=1:
            y.append(i)
            return y
        return y


Replace this line with your code.


#2

a function ends the moment a return a keyword is reached. If the function is executing a loop, the loop simply breaks


#3

aha, i get it. Really thanks for the help


#4

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