Review : Functions code error


#1




invalid syntax (python, line 2)


def shut_down(s):
    if s="yes":
    return ("shutting down")
    elif s="no":
    return ("shutdown aborted")
    else:
        return "sorry"
        
        shut_down(s)


#2

You should compare in an if condition, ===.


#3

I don't get it :frowning: What do you mean by : "You should compare in an if condition"


#4

You are trying to compare s to the string "yes", correct? You can't use one equal sign to do that, because one equal sign means you're setting it to something. You need to use two equal signs to compare, so it would look like

if s == "yes":

#5

I remember trying it with double "=" but it still got an error, this time it worked, I guess I forgot the >""< when writing the two equal sign code. Ty for help


#6

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