You are not logged in. Please login at www.codechef.com to post your questions!

×

Python, Error while taking input

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 <module>
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())

  1. I have checked the version, and it is Python 3 only. Hence, there is no problem with input()
  2. 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?

asked 24 Dec '18, 12:41

shubhamrajsrp's gravatar image

3★shubhamrajsrp
11
accept rate: 0%

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?

(24 Dec '18, 15:57) shivam_g14704★

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.

(24 Dec '18, 20:22) shubhamrajsrp3★

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())

link

answered 25 Dec '18, 00:03

violetval's gravatar image

3★violetval
1
accept rate: 0%

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.

link

answered 25 Dec '18, 00:23

abhi2402's gravatar image

5★abhi2402
1124
accept rate: 36%

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.

link

answered 25 Dec '18, 03:52

violetval's gravatar image

3★violetval
1
accept rate: 0%

I am also facing the same issue. Did anyone find a solution?

link

answered 05 Feb, 12:21

piyushkgp's gravatar image

2★piyushkgp
1
accept rate: 0%

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.

link

answered 05 Feb, 12:26

piyushkgp's gravatar image

2★piyushkgp
1
accept rate: 0%

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.

link

answered 05 Feb, 18:22

vichitr's gravatar image

5★vichitr
2555
accept rate: 11%

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(“..”)

link

answered 05 Feb, 18:54

ganeshkavhar's gravatar image

0★ganeshkavhar
112
accept rate: 0%

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...:)

link

answered 06 Feb, 02:15

chaudhary_19's gravatar image

4★chaudhary_19
11
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×422
×125
×42
×21

question asked: 24 Dec '18, 12:41

question was seen: 440 times

last updated: 06 Feb, 02:15