It is about review : functions lesson problem


but i have this
NameError: name 's' is not defined

this is the instructions

1- First, def a function, shut_down, that takes one argument s. Don't forget the parentheses or the colon!
2-Then, if the shut_down function receives an s equal to "yes", it should return "Shutting down"
3-Alternatively, elif s is equal to "no", then the function should return "Shutdown aborted".
4-Finally, if shut_down gets anything other than those inputs, the function should return "Sorry"
s expected to be an argument

def shut_down(s):
    return s 
if s == "yes" :
     shut_down ('shutting down')

elif s == "no" : 
     shut_down('shutting down aborted')

else : 


there are two problems with your code, a function ends the moment a return keyword is reached, in your case in the first line of the loop.

the if/elif and else should be inside the function:

der example():
if condition:
   print "if outside the function"


def example():
    if condition:
        print "inside the function"

also, you should return certain strings if a certain condition is met, instead of calling the function again


First of all, you want the if/elif/else statement inside your function. Second, you shouldn't be returning s. That'd defeat the purpose of the function if it just gave you whatever you put into it. Third, you shouldn't be passing the strings to the function, you should be returning them.


thank you a lot
i solved it right now


i follow yr advice and i passed the problem, thx