0

What's wrong with this EOF error user_input = str(input(":"))

print("options") print("enter'add'to add to numbers") print("enter'subtract'to subtract to numbers") print("enter'divide'to divide to numbers") print("enter'multiply'to multiply two numbers") print("enter'quit'to end the program") user_input = str(input(":")) if user_input="quit" 'break' If user_input == "add": num1 = int(input()) num2 = int(input()) result = str('num1 + num2') print("the answer is" + result) If user_input == "subtract": num1 = int(input()) num2 = int(input()) result = str('num1 - num2') print("the answer is" + result) If user_input == "divide": num1 = int(input()) num2 = int(input()) result = str('num1 / num2') print("the answer is" + result) if user_input == "quit": 'break' elif user_input == "multiply": num1 = int(input()) num2 = int(input()) result = str('num1 * num2') print("the answer is" + result)

4th Jun 2017, 2:41 PM
Dan Urey
Dan Urey - avatar
4 Réponses
+ 6
@Kuba: I did not really have doubt about you know that ;) It was essentially a figure of speech to complete your answer ;P
4th Jun 2017, 6:37 PM
visph
visph - avatar
+ 5
input() returns a string on its own, you don't have to convert it. Also, if user_input == "quit" it should break not 'break' EOF might have been reached in Sololearn' Code Playground as it does not handle input too well.
4th Jun 2017, 3:33 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
@Kuba: Sololearn handle input well, but with limitation of needing to give all user entries at once (separated by new lines) on script start, because of being executed on server side and not locally ;)
4th Jun 2017, 5:54 PM
visph
visph - avatar
+ 4
@Visph I know, I know. I just thought maybe the real answer would not be too easy to comprehend at once :) True, though. If you want to check how your input-based code works, you have to think through the whole input-wise logic beforehand ;)
4th Jun 2017, 6:23 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar