What is wrong with this? Practice Makes Perfect remove_duplicates


#1



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

I made a new variable to return, but it says i didn't

i expected lists_ to equal everything in lists, making everything in lists to make a new one


Replace this line with your code. 
def remove_duplicates(lists):
    lists_ = []
    for i in lists:
        if i == i:
            lists.remove(i)
            lists_ = lists[0:]
    return lists_


#2

this line:

lists.remove(i)

modifies the original list passed into the function, which is what is causing the error. You might want to modify this, if you need further assistant with it, let me know. (post an updated version of your code. Good luck :slight_smile:


#3

how would i set lists to a new variable? I tried using lists_ = lists but that wouldnt work.


#5

you have use the lists function:

lists_ = list(lists)

but i think the method you have now is better. Well done, i on purpose only gave you a small push in the right direction, i believe this teaches you more then a full answer.

Good to hear you resolved it :slight_smile: