简体   繁体   中英

if (input == operator): not working in python calculator?

print ("THE CALCULATOR")

print ("Type 1st no")

n = input()

print("Type 2nd no")

n2 = input()

print("Which Operator?")

n3 = input()

if (n3 == +):

    print("The anwser is", int(n) + int(n2))

Change:-

if (n3 == +):

To:-

if (n3 == '+'):

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM