It is about review : functions lesson problem


#1



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


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 : 
    shut_down("sorry")


#2

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():
   pass
if condition:
   print "if outside the function"

and:

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


#3

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.


#4

thank you a lot
i solved it right now


#5

i follow yr advice and i passed the problem, thx


#6