EOFError | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

EOFError

What is EOF ? How to fix EOFError ?

30th May 2018, 4:35 AM
Lewsijght G
Lewsijght G - avatar
4 Answers
+ 2
you should use try/except when reading your input string, and if an EOF error has been risen you could set the check to an empty string before printing its content, for example: try : 1 check = raw_input ("would you li 2 except EOFError : 3 print ("Error: EOF or empty inpu 4 check = "" 5 print check
30th May 2018, 4:47 AM
Andrew Watts
Andrew Watts - avatar
+ 2
exception EOFError. Raised when one of the built-in functions ( input() or raw_input() ) hits an end-of-file condition (EOF) without reading any data. (N.B.: the file.read() and file.readline() methods return an empty string when they hit EOF.) exception FloatingPointError. Raised when a floating point operation fails.
30th May 2018, 4:48 AM
Andrew Watts
Andrew Watts - avatar
+ 2
EOF happens when there is something that needs to be read but there is no closing of inverted commas or brackets, for example. In input(), it is sys.stdin, the file for inputting. When your code is the one doing that, your __file__ gives EOFError
30th May 2018, 4:52 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
End Of File Error. You can read about Python Errors here: https://docs.python.org/2/library/exceptions.html Also, if you show us a specific code where the error occurs, we can help you find out why :)
30th May 2018, 6:09 AM
Pedro Demingos
Pedro Demingos - avatar