+ 2
Getting a syntaxError when doing this:
So I'm trying to run the following code: userInput = input() if userInput = "yellow": (the error happens here) print("invalid color") Else: print("finished") So i put yellow when it asks for input but get a syntaxError. Any help?
2 Réponses
+ 7
You are using the assignment operator (=) in the if statement instead of the equal to operator (==). It should be like this:
if userInput == "yellow":
By the way, the else stament has to be in lowercases (else instead of Else) or you will get another error.
Hope it helps
+ 1
Python doesn't test if assignment (=) works. Use equivalence (==) instead.
'else' should be all lowercase.