Review Functions :I'm not getting the right code


#1

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")
else:
return shut_down("Sorry")

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


#2

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.


#3

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

`


#4

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