Error Message: EOF Error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Error Message: EOF Error

Trying to code a calculator from my lesson Please what does the error message mean and how do i resolve it Check valid link below Traceback (most recent call last): File "./Playground/file0.py", line 8, in <module> user_input = input(":") EOFError: EOF when reading a line https://code.sololearn.com/cGvUsbJVPnYB/#py

23rd Apr 2020, 10:47 AM
Tega Somuvie
Tega Somuvie - avatar
9 Answers
+ 2
I added a comment in ur code Minor prob😊
23rd Apr 2020, 11:12 AM
Oma Falk
Oma Falk - avatar
+ 2
elif user_input == "add": num1 = float(input("Enter a number:")) num2 = float(input("Enter another number:")) result = (num1 + num2) print("The answer is", result) break ... ... else: print("Unknown input") break
23rd Apr 2020, 11:18 AM
Solo
Solo - avatar
+ 2
Add brackets to the "input()" and everything will work. Since you are using a loop, then look carefully at what commands you constantly repeat and try to shorten the code.
23rd Apr 2020, 5:07 PM
Solo
Solo - avatar
+ 1
Instead of placing link to code in the tag area mention the language ,ty
23rd Apr 2020, 10:55 AM
Abhay
Abhay - avatar
+ 1
And that link took me to this thread only ,weird ,anyway post link to your code using insert code , If I could see your code ,it would be easy to find error input looks right to me tho
23rd Apr 2020, 10:58 AM
Abhay
Abhay - avatar
23rd Apr 2020, 11:06 AM
Tega Somuvie
Tega Somuvie - avatar
0
You weren't inputting in right format I guess This is how it should be add 4 5 Also convert that result to string Also use break to prevent while loop to keep running and asking input from user You have to input all the inputs at one time only ,it doesn't let's you give input one by one ,so that's why it was causing end of file error
23rd Apr 2020, 11:18 AM
Abhay
Abhay - avatar
0
Thanks Vasily, Abhay, Oma Falk i had to change the user_input on line 8 to this user_input = input and i also used "break" to prevent the while loop from running infinitely. Thanks. Check the link below for the modified code and tell me what you think https://code.sololearn.com/cGvUsbJVPnYB/#py
23rd Apr 2020, 4:42 PM
Tega Somuvie
Tega Somuvie - avatar
0
EOF stands for End of File in Python. Unexpected EOF implies that the interpreter has reached the end of our program before executing all the code. This error is likely to occur when: we fail to declare a statement for loop ( while / for )
11th Jan 2023, 7:13 AM
Mike Clark
Mike Clark - avatar