Remove_duplicates marked successful but NOT WORKING


#1



Hi everyone Codecademy says that my code is right, but it's not actually removing duplicates like it's supposed to. I can't understand why.


https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/2/4?curriculum_id=4f89dab3d788890003000096#

This is my code:


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

print ([1,1,2,2])

Thanks!


#2

What makes you say it isn't removing duplicates, got an example of input that it fails on?


#3

so when I asked to print ([1,1,2,2])

it prints [1,1,2,2]


#4

That doesn't involve your function though, you're just printing a list without doing anything with it first


#5

oh wow you're right! Can't believe it was that simple. I must be tired.

Thanks :slight_smile:


#6

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