Remove_duplicates practice makes perfect 14/15


#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/courses/learn-python/lessons/practice-makes-perfect/exercises/removeduplicates?action=lesson_resume

<In what way does your code behave incorrectly? Include ALL error messages.>

File “python”, line 6
SyntaxError: ‘return’ outside function

<What do you expect to happen instead?>

 def remove_duplicates(n):
 m = []  
for i in n:
    if i not in m:
        m.append(i)
        return m
print remove_duplicates([4,5,5,4])

#2

are you sure you copied your code correctly to the forum? The indent looks off

please post your code again with markup:

so indent shows properly (which is important to solve your problem)

anyway, the problem is that your for loop doesn’t seem to be part of the function, so return is outside the function.


#3

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