What is wrong with this? Practice Makes Perfect remove_duplicates


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/pt/courses/python-intermediate-en-rCQKw/2/4?curriculum_id=4f89dab3d788890003000096#
<In what way does your code behave incorrectly? Include ALL error messages.>
I made a new variable to return, but it says i didn’t
<What do you expect to happen instead?>
i expected lists_ to equal everything in lists, making everything in lists to make a new one

```python

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_

<do not remove the three backticks above>

#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: