Review function<anyone spotting my wrong doing?


#1

Continuing the discussion from Review: Functions:



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

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"
else:
  return "sorry"


#2

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!


#3

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