0

Calclulator code not working

my code is not working. below is the code and error message, can anybody help while True: print("Options:") print("Enter 'add' to add two numbers") print("Enter 'subtract' to subtract two numbers") print("Enter 'multiply' to multiply two numbers") print("Enter 'divide' to divide two numbers") print("Enter 'quit' to end the program") user_input = input(":") if user_input == "quit": break elif user_input == "add": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 + num2) print("The answer is " + result) elif user_input == "subtract": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 - num2) print("The answer is " + result) elif user_input == "multiply": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 * num2) print("The answer is " + result) elif user_input == "divide": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 / num2) print("The answer is " + result) else: print("Unknown input") ptions: Enter 'add' to add two numbers Enter 'subtract' to subtract two numbers Enter 'multiply' to multiply two numbers Enter 'divide' to divide two numbers Enter 'quit' to end the program :Enter a number: Enter another number: The answer is 5.0 Options: Enter 'add' to add two numbers Enter 'subtract' to subtract two numbers Enter 'multiply' to multiply two numbers Enter 'divide' to divide two numbers Enter 'quit' to end the program : Traceback (most recent call last): File "./Playground/file0.py", line 8, in <module> user_input = input(":") EOFError: EOF when reading a line

13th Feb 2020, 4:24 PM
Shabbir Sultan
3 Answers
0
Thanks a lot for your reply. Will surely try on PC
14th Feb 2020, 5:46 AM
Shabbir Sultan
0
I checked on PC and it worked. thanks a lot for your support
14th Feb 2020, 10:57 AM
Shabbir Sultan