14. Remove duplicates


#1

def remove_duplicates(numbers):
    new_list = []
    for i in numbers:
        if i not in new_list:
            new_list.append(numbers)
    return new_list

"ops, try again. remove_duplicates([4, 5, 5, 4]) returned [[4, 5, 5, 4], [4, 5, 5, 4], [4, 5, 5, 4], [4, 5, 5, 4]] instead of [4, 5]"

Can someone tell me why it does this and how i can fix it to work properly? thanks:)


#2

you append numbers to the new_list, but what is numbers? It is the list with all the numbers. Try appending the individual numbers to the new_list, which variable do you think you need for this, and why?


#3

oh right, im such a fool. thank you :slight_smile: