vendredi 21 juin 2019

If Else statement giving an invalid syntax error on equal sign?

I have a simple if else statement that is giving me troubles, for some reason the equals sign is giving off an invalid syntax.

I've tried changing the = to an == but it wont give me the if statement but rather the else statement even though the input is corresponding to the if statement.

print("type in the corresponding number")
print("1")
print("2")
menuvar=int(input())
if menuvar = 1:
    print("good")
elif menuvar = 2:
    print("bad")
else:
    print('no')

I'm expecting the output to be good when i input 1 and bad when I input 2

Aucun commentaire:

Enregistrer un commentaire