Remove duplicates


#1


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

Can anyone tell me what I go wrong in my code I get the right answer from another answer but coudln't find out what go wrong with my code


def remove_duplicates(lis):
    newlis=[]
    for i in lis:
        if i in newlis:
            lis1.remove(i)
        newlis.append(i)
    return newlis


#2

here:

lis1.remove(i)

where does lis1 come from? Its undefined

you are not allowed to modify the list passed into the function (lis)


#3

actullly its a fault
earlier I modified the code second line as

lis1 = lis
and change every "lis" as "lis1" but still I got wrong

sorry for the mistake


#4

is your problem solved now? If not, post an updated version of your code + question


#5

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