SyntaxError: 'return' outside function


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"
    return "Sorry"


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


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.


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