Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (18.4k points)

I can't run the below code, I am using atom.io, python 3.7. 

num1 = input("enter a number: ")

num2 = input("enter another number: ")

result = int(num1) + int(num2)

print(result)

This is the error:

enter a number: Traceback (most recent call last):

  File "C:\Users\icebergnes\Desktop\CODE\Calculator Basic.py", line 2, in <module>

    num1 = input("enter a number: ")

EOFError: EOF when reading a line

1 Answer

0 votes
by (36.8k points)
edited by

The EOFError is raised when the built-in function like input() or raw_input() does not read any data before encountering the end of their input stream.

Using the try-except to check if it works.

try:

   #your code

except EOFError as e:

   print(e)

Learn Data Science with Python Course to improve technical knowledge.

Browse Categories

...