Guide eoferror: eof when reading a line coding

 

EOFError is raised when one of many built-in features input() or raw_input() hits an end-of-file situation (EOF) with out reading any knowledge. This error is typically skilled whereas utilizing on-line IDEs. This happens when we now have requested the person for input however haven’t offered any input within the input field. We can overcome this situation by utilizing try and except key phrases in Python. This known as as Exception Handling.

Example: This code will generate an EOFError when there isn’t a input given to the web IDE.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and study the fundamentals.

To start with, your interview preparations Enhance your Data Structures ideas with the Python DS Course. And to start along with your Machine Learning Journey, be a part of the Machine Learning – Basic Level Course

Python3

n = int(input())

print(n * 10)

Output:

 

This exception might be handled as:

Python3

try:

    n = int(input())

    print(n * 10)

   

except EOFError as e:

    print(e)

Output:

EOF when reading a line

Add a Comment

Your email address will not be published. Required fields are marked *