I try to run the program but it comes up with a invalid syntax error and highlights the colon
if operation==+ :
print("Your answer is ", number1+number2)
Take note that there is no type to represent the value +
. You probably had a string representing the +
, i.e. "+"
. To do the correct comparison, you should replace your former code with:
if operation == "+" :
print("Your answer is ", number1+number2)
If operation
is not a string, but an operator
from the imported module, you should use:
if operation == operator.add:
print("Your answer is ", number1+number2)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments