Codecademy - Functions in Python Excercise



While learning Python at Codecademy, I just got stuck up at Functions. Though, I managed to clear most of the part but the review section caught me.

Here is the question which I am trying to solve:

  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”

  1. 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”

I tried it in every possible manner, but I am frequently getting traceback, syntax error.



What exactly were your attemps, @jaskey12. We would be able to help you better if we saw your code. (Please use the code tags in the post editor so that formatting is maintained.)


Hi @jaskey12,

This worked for me:

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

Then call the function with the mentioned values :-

Hope this helps!!


@shuvayan, please don’t take this wrong way when I say that simply having the answer offered to you isn’t the best way to learn from one’s mistakes.