Calculator on Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Calculator on Python

Why is this code not working? number1 = int(input("What is your first number?")); operator = input("What is your operator?"); number2 = int(input("What is your second number")); if operator == "+": answer = number1 + number2; elif operator == "/": answer = number1 / number2; elif operator == "*": answer = number1 * number2; elif operator == "-": answer = number1 - number2; print("The answer is" + str((answer)

4th May 2020, 3:59 PM
Leon Shrestha
Leon Shrestha - avatar
3 Answers
+ 1
I will see if it works
4th May 2020, 4:33 PM
Leon Shrestha
Leon Shrestha - avatar
+ 1
It works which means I am an idiot. Thanks!
4th May 2020, 4:39 PM
Leon Shrestha
Leon Shrestha - avatar
+ 1
i = input() print(i," = ",eval(i))
5th May 2020, 7:26 PM
Sharapudin Dibirov
Sharapudin Dibirov - avatar