Review: Functions


#1

I get an error saying "File “python”, line 4
SyntaxError: ‘return’ outside function"
I don’t know why I get this error as my indentation and spacing seems correct? What am I missing here?

def shut_down(s):
return s
if s == “yes”:
return (“Shutting down”)
elif s == “no”:
return (“Shutdown aborted”)
else:
return (“Sorry”)


#2

Btw, how do I link my code, so the prober indentation is applied to the post? It seems that my code is not indented at all


#3

Fixed it. It seems that I forgot to indent my if statement.


#4

for next time, use format:

so the indent shows up, so we can help you with this kind of issue, do you understand it now?


#5

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