mardi 9 mai 2017

Python: Simple if: statement that says invalid syntax [duplicate]

This question already has an answer here:

I keep on getting invalid syntax on line 2 and I'm not sure what I'm doing wrong.

operator = input("Would you like to +, -, *, or /?:")
if (operator != "+"):
  print ("Unknown operator!")

I also attempted to do:

operator = input("Would you like to +, -, *, or /?:")
if (operator != "+" or "-" or "*" or "/"):
  print ("Unknown operator!")

But then it always print out "Unknown operator!"

I'm honestly very new to coding and any help would be appreciated! Thanks!

Aucun commentaire:

Enregistrer un commentaire