EOFError

Built-in ExceptionPython 2.0+Intermediate

Raised when input() hits end-of-file without reading data

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# Triggering and catching EOFError
try:
    raise EOFError("unexpected end of file")
except EOFError as e:
    print(f"Caught EOFError: {e}")
    print(f"Type: {type(e).__name__}")

EOFError is raised when raised when input() hits end-of-file without reading data. Always catch specific exceptions rather than bare except clauses.

Try in Playground

Tags

exceptionerror-handlingcore