jeudi 25 janvier 2018

How do I use or in Python 3.6

So I'm making a calculator in python 3.6, but I cant get the error message to work.

if(op == "+"):
    print(add(num1, num2))
if(op == "-"):
    print(sub(num1, num2))
if(op == "*"):
    print(mul(num1, num2))
if(op == "/"):
    print(dev(num1, num2))
if(op == "stop"):
    rng = "f"
elif(op != "+", or "-", or "*", or "/", or "stop"):
    print("Please enter a valid operation!")

When I run the code, it gives me an error saying invalid syntax and highlights the "or" part in the string. Error Picture. How do I fix this?

Aucun commentaire:

Enregistrer un commentaire