I have been working with Python 3 for quite a while, however, I am new to CodeChef. I have tried to solve quite a few practice problems using CodeChef IDE. However, every time I try to run it, I get the following error.
Traceback (most recent call last):
File “./prog.py”, line 1, in
EOFError: EOF when reading a line
I try running the same code with custom input and it works perfectly. The first line of my code, where the error occurs is the following:
t = int(input())
- I have checked the version, and it is Python 3 only. Hence, there is no problem with input()
- The first line of input is a single integer, hence, converting the string into int should not be an issue. For more details, i am sharing the link to the problem as well which I am trying to solve.
Link: here
I also tried the following:
import sys
inp=sys.stdin.read()
print(inp)
In this case, the output was nothing. Can someone help me out with what the problem is actually?
You are getting EOF error. That means there was no input but you still tried to read something. Can you share your submission link for which you are getting this error?
Hi,
The link to my solution is the following:
https://www.codechef.com/viewsolution/22062856
This code worked perfectly during the competition, but it is not running in the ide. I have been getting the same error for all the problems that I have attempted so far in ide.
Thanks for your help.
I am having the same problem, except I got the error both in competition and with the ide. I would also appreciate a solution. The error is occurring with this line:
t = int(input())
If your code takes some input, then you have to provide custom input for your program otherwise it will show NZEC error. Just provide an appropriate input and it works fine.
For the contest and practice submissions, isn’t codechef supposed to provide the input? I’m getting that error with contest and practice submissions. I notice my code works on some online compilers and not others, with codechef being one of the compilers it doesn’t work on.
I am also facing the same issue. Did anyone find a solution?
Hey, you guys should try just submitting. It works. I think ‘RUN’ and ‘SUBMIT’ run on different compilers/machines and ‘RUN’ is broken right now.
If you are trying to run the code in IDE mode then you must provide custom input, otherwise you will get NZEC.
This is the only reason you are getting this error. If you wanna submit then just submit. So RUN and SUBMIT both are different functionalities. In case of SUBMIT, codechef gives it’s test cases. But in case of RUN, you should give input.
Text Input
Want to get keyboard input?
To get keyboard input, use the input function. Inside the terminal you’ll be able to type text.
In Python 3 you can use the input() function, older versions of Python have the raw_input() function.
Related Courses: Python Crash Course
User Input
The input function has a return variable. In this case the keyboard input. If we do not store the return variable into a programs variable, we lose it. That’s why we write a variable to store the result in.
To get a text value:
name = input("Enter a name: ")
print(name)
This will show you:
Enter a name:
You can now give keyboard input, it will be stored in the variable name.
Note: don’t forget to store the return variable. variable = input(“…”)
I was also facing the same issue 2 days back…when I was in a competition organized by Jaypee College…It really sucks…I think some times using strip() with input helps…