What does this mean what's wrong?


#1

Hey I tried this:

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

File "python", line 4

SyntaxError: 'return' outside function ##

What does this mean what's wrong?


Review Functions.. Help me out
#2

Python is sensitive to indentation. If your code is badly indented, it won't work.

in your function remove

return s

Dont need that. after return statement it'll not go to the next.

your code should be indented like

def shut_down(s):
    if s == 'yes':  # 4 spaces before if statement 
        return "Shutting down"  # 4 spaces before return
    elif s == 'no':

so on.....


#3

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