I don't understand why my code does not work, it looks correct to me?


This is the code I am trying to run:

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


It gives an invalid syntax error message

I was expecting for me to get a a prompt to type so it will go through the If, elif, else loop.

Replace this line with your code.


Is there a reason for the immediate return(s) statement?

In truth, we saw this exact code last week. Are you sure you wouldn't be up to just starting the whole thing over, reading from the instructions each step, one at a time?


well its very small piece of code, sure I can rewrite it but I don't really understand what is it that's wrong with it? Why can I not have a return function in there?


isn't all I am doing is creating an if statement with several options, if this return this, elseif this return that, etc??


The immediate return means none of the code runs. It just returns s, the same parameter it is passed. That line needs to be removed so the if statement executes. There are other problems that we will soon discover.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.