Why Does Codechef Give Nzec Eoferror: Eof When Reading A Line For Input() On Python3.6
The following code runs fine on PyCharm but the CodeChef IDE simply won't take it. Am I missing something here? Please convince me I'm a fool for sitting on this all day I even tri
Solution 1:
Focus on EOFError: EOF when reading a line
It happens because the code needs an input from command line, but the file that provides the input is empty.
n =int(input())
consider the above line. It'll expect an input but it will get EOF delimiter as soon as it reads the file.
Hence, raising an EOFError.
Solution 2:
Insist of using input() method to take input from user you can use stdin(standard input).
Simply import sys.stdin and use n=eval(stdin.readline()) to take input. Also put your code inside try and execpt EOFError.
Sample -
from sys import stdin
try:
n=eval(stdin.readline())
# write your code hereexcept EOFError:
print("EOFError")
Post a Comment for "Why Does Codechef Give Nzec Eoferror: Eof When Reading A Line For Input() On Python3.6"