What is wrong here?


#1



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

Oops, try again. Your remove_duplicates modifies the list that was passed to it. [4, 5, 5, 4] was modified to [5, 4]. Perhaps you should make a copy first!


def remove_duplicates(l):
    a=l
    t=[]
    r=[]
    for s in a:
        if s not in t:
            r.append(s)
            r.append(t)
            a.pop(0)
    b=a
    return b


#2

When you do a = l, you are not creating a new list a with all the items in l. a = l basically binds two variable names to one list (you can now call list l as a or l). So if you change things using a, it will persist to l and vice versa. I suggest you try to make a copy of the list l with a different method.

You can slice it using
a = l[:]

or
a = list(l)