+ 1

What does an EOFError is?

4th May 2020, 6:07 PM
Kevinator
10 Antworten
+ 3
Please post your complete code in playground and link it here. We need to see the code to find out why the error is happening.
4th May 2020, 6:15 PM
Lothar
Lothar - avatar
+ 2
EOFError means End Of File error. It is thrown when nothing is inputted.
4th May 2020, 6:09 PM
AA Shakil
AA Shakil - avatar
+ 1
Yup, i usually get it when im missing an end parenthesis or something similar
4th May 2020, 6:10 PM
Slick
Slick - avatar
+ 1
An EOFError is raised when a built-in function like input() or raw_input() do not read any data before encountering the end of their input stream. The file methods like read() return an empty string at the end of the file. The given code is rewritten as follows to catch the EOFError and find its type.
5th May 2020, 6:42 AM
SITHU Nyein
SITHU Nyein - avatar
+ 1
There are several reasons that causes errors in the current code: - When an odd number is entered, you run in an infinite loop with the while ... loop. Even if you enter an even number in the second try, iyou are caught in this loop. So this needs a correction with a break. - If the same case happens in sololearn playground, you get an EOF error, because there is no input done for this case (repeated input) - The input in the while loop should also convert the entered number to int, as it's done with the first input . To get rid of these things, you should modify your code like this: while int(comprobation)!=0: print("It must be an even number") number=int(input("Enter a number: ")) if number % 2 == 0: break
5th May 2020, 10:40 AM
Lothar
Lothar - avatar
0
It works fine man
4th May 2020, 6:29 PM
Slick
Slick - avatar
0
Kevinator It works fine in case of even number input. But cause error when we enter odd number. The reason is that in case of odd number while loop executes and it prompt user for input but due to limitations of sololearn playground we can'nt give any input at runtime so that's why error occured. If you try same code on any other ide it works fine.
4th May 2020, 6:45 PM
Muhammad Bilal
Muhammad Bilal - avatar
0
If you input an odd number it shows the error
4th May 2020, 6:47 PM
Kevinator
0
Thanks for everything
4th May 2020, 6:48 PM
Kevinator