I typed the exact same code but it doesn’t work. All I get is
File “python”, line 3
if s == “yes”:
^
IndentationError: expected an indented block
and here is my code
def shut_down(s):
if s == “yes”:
return “Shutting down”
elif s == “no”:
return “Shutdown aborted”
else:
return “Sorry”
yes and no should be written in all lower case.
the input is yes not Yes. because you are using ‘Yes’ and the computer is inputting ‘yes’ it is going by else : return ‘Sorry’. Worked for me
def shut_down(s):
if s == “yes”.upper() or s == “yes”.lower() or s == “yes”.capitalize():
return “Shutting down”
elif s == “no”.lower() or s == “no”.upper() or s == “no”.capitalize():
return “Shutdown aborted”
else:
return “Sorry”
No, but I found out where the problem was. All the if conditions must be indented as part of the function itself and (everything from def to “Sorry”) and then there’s another line needed that will call the function for either (yes) or (no).
HI to all the people that will have a problem in this lesson also to @lechaim #FUNCTION 17/19 DO you know ho to create a function? Do you know how to create a if statement inside a function that will use the parameter of the function? TO those question I will respond for you "YES, WE DO!"
This Lesson doesn’t aske you to do something you don’t know it only aske you to…
01. First, def a function, shut_down, that takes one argument s. Don’t forget the parentheses or the colon!
def shut_down(s):
The this part is about the if statement inside the function 02. Then, if the shut_down function receives an s equal to “yes”, it should return "Shutting down"
the if condition is write this part s equal to "yes" so inisde it you will do
def shut_down(s):
if s == "yes":
return "Shutting down"
03. Alternatively, elif s is equal to “no”, then the function should return “Shutdown aborted”.
def shut_down(s):
if s == "yes":
return "Shutting down"
elif s == "no":
return "Shutdown aborted"
04. Finally, if shut_down gets anything other than those inputs, the function should return "Sorry"
def shut_down(s):
if s == "yes":
return "Shutting down"
elif s == "no":
return "Shutdown aborted"
else:
return "Sorry"
#AND
if you want something to be print just add this line at the end of your code