Review function<anyone spotting my wrong doing?


Continuing the discussion from Review: Functions:

File "python", line 4
return "Shutting down" elif s=="no"
SyntaxError: invalid syntax
I expected my code to run

def shut_down(s):
 return s  
if s=="yes":  
 return "Shutting down"                              
 elif s=="no"
 return "Shutdown aborted"
  return "sorry"


Hi @sixpack8,

Why did you place this directly after defining the function? Remember that a return statement will effectively terminate a function, but in this case you don't want the function to end that quickly.

The instructions state that:

if the shut_down function receives an s equal to "yes", it should return "Shutting down"

so you see, all the if and elif and else statements should be done within the function body (i.e. indented) instead.

Don't let the sample code muddle you!


Thanks buddy I figured it out,in most cases its the indention concept that's hard to grasp.