Why Does This Not Work?


#1

Why, when I use:


def shut_down(s):
  return s

if s == "yes":
  return "Shutting down"
elif s == "no":
  return "Shutdown aborted"
else:
  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
#2

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