Review Functions :I'm not getting the right code


my codes are as follows:-

def shut_down(s):

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

this is the error:-
File "python", line 3
if s = "yes":
SyntaxError: invalid syntax


First off, you need to have a double equals sign when comparing values (==) e.g. in an if statement.
I believe that's the error, since a single equals sign is reserved for assigning variables.

Also, when posting a question in Python please make sure that the code is properly formatted with indentation because it really helps when we read the code, allowing us to be of more help.


def shut_down(s):
   return s
if s == "yes"
   shut_down("Shutting down")
elif s == "no":
  shut_down("Shutdown aborted")
type or paste code here



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