+ 1

Error in The Python Simple Calculator

for this code---- 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(": ") num1=float(input()) num2=float(input()) if user_input == "quit": break elif user_input == "add": print(num1+num2) elif user_input == "subtract": print(num1-num2) elif user_input == "multiply": print(num1*num2) elif user_input == "divide": print(num1/num2) else: print("Unknown input") by entering inputs-- add 2010 7 output I get--- 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 : 2017.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\", line 8, in <module> user_input = input(": ") EOFError: EOF when reading a line can anyone pls help?

18th Sep 2017, 5:17 PM
Abhishek Sarkar
Abhishek Sarkar - avatar
3 Answers
+ 11
You get the EOFError when you don't satisfy all the inputs your code needs. Remember, the playground says 'split multiple inputs into separate lines'. Your code requires more than multiple inputs.
18th Sep 2017, 5:32 PM
Dev
Dev - avatar
0
I entered it like this--- add 2010 7 should i also include "quit"? like--- add 2010 7 quit
18th Sep 2017, 6:46 PM
Abhishek Sarkar
Abhishek Sarkar - avatar
0
I still cannot figure this out can someone help??
5th Sep 2019, 9:31 PM
Tabari isreal
Tabari isreal - avatar