Why Does This Not Work?


Why, when I use:

def shut_down(s):
  return s

if s == "yes":
  return "Shutting down"
elif s == "no":
  return "Shutdown aborted"
  return "Sorry"

does it not work because of the first “return s”? Simply removing that and fixing all the indents allows me to continue the lesson.

FAQ: Learn Python: Functions - Review: Functions

the example is this lesson uses a very design then the program you need to build

yes, because by default, a function returns None at the end of the function. If we want to return something else at the end of the function, we can use the return keyword.

Given return is the last thing a function does, when a return keyword is reached, the function ends