Cannot get function with if else statement to work (lesson 17. Review: Functions)


#1
  1. Review: Funtions

I am missing something here but I cannot figure out what. Below see my code for the exercise.

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

#2

Please format your post before posting it as I have done (select code block; press Ctrl+Shift+C) from next time. Thanks! :slightly_smiling:

Why do you have return s in the first line of the method? That would cause the function to stop executing and return whatever string had been passed as an argument. You surely don't want that to happen.

Can you now fix the error?


#3

This is my code .thanks for your comment