+ 1

Why my calculator does not work?

I'm just a tyro so be gentle :D https://code.sololearn.com/cn3IULi6M187/?ref=app

3rd Apr 2019, 11:56 PM
Seyfullah Özdağlar
Seyfullah Özdağlar - avatar
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")
4th Apr 2019, 12:26 AM
Hatsy Rei
Hatsy Rei - avatar
0
Thank you so much
4th Apr 2019, 7:53 AM
Seyfullah Özdağlar
Seyfullah Özdağlar - avatar