EOFError: EOF when reading a line

Why do I get ( in the Codecademy console) :
Weight = Traceback (most recent call last):
File “script.py”, line 1, in
weight = float(input("Weight = "))
EOFError: EOF when reading a line

for this code:

weight= float (input("weight = "))
print (weight)

Result in Thonny :

weight= float (input("weight = "))
print (weight)

%Run weight.py
weight = 12
12.0

In Python 3.8.2 Shell:

weight= float (input("weight = "))
weight = 12

print (weight)
12.0

Hey there and welcome to the forums!! :slightly_smiling_face:

This question arises every so often, and it is due to the fact that not all of Codecademy’s lessons have a console capable of accepting input. This throws an EOFError , or End Of File Error, when it tries to collect input and cannot.

For the Codecademy lessons, any project requiring the use of an input() should be capable of accepting input, otherwise you have to hard code your answer.
For example, instead of:

weight = float(input(">>> "))

Use:

weight = 135.0

You can of course rewrite your program to use input() on your computer, or using an online IDE such as repl.it.

1 Like