Ok, so where did I got wrong with shut_down?


#1

def shut_down(s):
return s

if s == "yes":
shut_down("Shutting down")
elif s == "no":
shut_down("Shutdown aborted")
else:
shut_down("Sorry")


#2
def shut_down(s):
    return s

if s == "yes":
    shut_down("Shutting down")
elif s == "no":
    shut_down("Shutdown aborted")
else:
    shut_down("Sorry")

I don't remember clearly what was the objective of that exercise, but I suposse that you want to output those string in the terminal. You are returning, not printing, so you need to print(shut_down(..)).


Reveiw Functions
#3

There's no definition for "s" outside of the function.

"return" stops the function. So your function is starting, returning "s" without doing anything with it, and then stopping.

Also, your "if" and "elif" statements are calling shutdown again. You should be returning an answer, not calling the function again.

Your program should do something like this:

define shutdown (accepting input s):
....if s is "yes":
........return "shutting down"
....if s is "no":
........return "shutdown aborted"
....else:
.......return "sorry"

Just put that in proper Python code.


#4

copy, paste and run ,,,,, :+1:

def shut_down(s):

if s == "yes":
 return "shutting down"

elif s == "no":
 return "shutdown aborted"

else:
 return "sorry"

#5

Yeah, you're right, sorry that I didn't updated my reply, the right code is in another topic of the same http://discuss.codecademy.com/t/reveiw-functions/8797/6


#6

Finally I got it....thanks guys


#7

def shut_down(s):

if s == "yes":
   return "Shutting down"

elif s== "no":
   return "Shutdown aborted"
else:
   return "Sorry"