def shut_down(s): if true(): return "Shutting down" elif no(): return "Shutdown aborted" else: return "Sorry"
You function is supposed to return "Shutting down" when s is "yes".
if s == "yes" return "Shutting down"
You also need to change the elif part to check if s is "no".
I just wanted to highlight a conceptual misunderstanding. Please note the line of code you wrote:
return "Shutting down"
The parentheses () denotes a function (e.g. def shut_down()). The parentheses is where you would add an argument for the function.
So you are telling the interpreter that you are calling functions, true() and no() that you have yet to create.
The exercise wanted to evaluate the argument in the function shut_down(). You have defined the function with the following code:
def shut_down(s): #where (s) will be the argument that the user will input
if s == 'yes': #please ignore the indentation as it is off - two equal signs means that the s is equal to 'yes', remember you need to add the quotation in order to be read as a string, I made this mistake
return "Shutting down" #this is the output that will be returned if the argument s is equal to yes (e.g. the input the user puts in is equal to s)
if s == 'no: #s is the argument that the user puts into the function shut_down(s)
return "Shutdown aborted"
I hope this is clear and again the indentations need to be correct or python will not be able to interpret the code.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.