Review: functions shut_down exercise syntax error


#1

I’m struggling with the shut_down exercise in review: functions. If the shut_down function receives an s equal to “yes”, it should return “Shutting down”. Why am I getting a syntax error here? :thinking: Code is posted below the error message.

File “python”, line 2
if (s = “yes”)
^
SyntaxError: invalid syntax

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

shutdown


#2

Hi @cannonball_g,

It looks like you’re doing s = "yes" (which acts like assigning a value to a variable)
where you want to do s == "yes" (which checks if the variable s is equal to “yes”)

It’s a common mistake that takes practice to spot and overcome. Hope this helps! :smile:


#3

Ahh, that makes total sense. Thanks for the enlightenment! :call_me_hand:


#4

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