SyntaxError: 'return' outside function


#1



https://www.codecademy.com/en/courses/python-beginner-c7VZg/4/1?curriculum_id=4f89dab3d788890003000096

Upon entering the code, I receive: "File "python", line 5
SyntaxError: 'return' outside function"

I believe the code is correct, yet I could be wrong.


def shut_down(s):
    return s

if shut_down() == "yes":
    return "Shutting down"
elif shut_down() == "no":
    return "Shutdown aborted"
else: 
    return "Sorry"


#2

i think you misunderstand instructions ;
you should code the if , elif.. inside the function !!


#3

a function ends the moment a return keyword is reached. In the first line of your function return is reached.

You should put the if/elif/else inside the shutdown function, and then compare "yes", "no" with s (the variable inside your function)

look at this simple function with a function call:

def example(s):
   print s

example("hello world")

now, you pass a argument into the function, which you then print.


#4

Yeah so...indent your 'if" statements, and no need to call on the function in each comparison, just (s).