Remove duplicates


#1
def remove_duplicates(numbers):
       new_list = []
for item in numbers: 
        if item not in numbers: 
          new_list.append(item)
      return new_list

I don’t understand where is my problem here?


#2

look at this line:

if item not in numbers:

what is this line suppose to do? Is it actually doing that task?

also, what is currently in the function body? Is the for loop in the body of the function? Should it be?


#3

Hi @betarunner60954,

What error message or other event occurred that indicated that there was a problem with your code?


#6

File “python”, line 6
return new_list
^
IndentationError: unindent does not match any outer indentation level


#7

what about the other questions i asked:


#9

a bit with correction

def remove_duplicates(numbers): 
       new_list = []
    for item in numbers: 
        if item not in new_list:      -the line supposed to check if item not in new_ list 
          new_list.append(item)
        return new_list

File “python”, line 3
** for item in numbers:**
** ^**
IndentationError: unindent does not match any outer indentation level


#11

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