+ 1
Why my calculator does not work?
I'm just a tyro so be gentle :D https://code.sololearn.com/cn3IULi6M187/?ref=app
2 RĂ©ponses
+ 6
You're casting z to int, but you are comparing z to string literals, which is really not gentle! You either remove the cast, or compare z to integers.
x = int(input("firstnumber: "))
y = int(input("secondnumber: "))
z = input("operation: ")
if z == "1" :
print (x+y)
elif z == "2" :
print (x-y)
elif z == "3" :
print (x*y)
elif z == "4" :
print (x/y)
else :
print ("invalid operation")
0
Thank you so much