Taking input Python

Hello, I am a rookie programmer and only recently started using CodeChef. I was testing out the CodeChef ide and realised that I got an error everytime i tried to take input on the Python ide. The error triggered for both the input() and raw_input() functions.If someone could suggest a fix or an alternative method of taking input, I’d appreciate it.
My code:

x = input()

Error:
Traceback (most recent call last):
File “./prog.py”, line 2, in
EOFError: EOF when reading a line

try to provide some input in custom input and then run

1 Like

Yeah you had not given any custom data.

EOF error results usually in an online judge like CodeChef when an input is given by the system but the input reading line is not at the right place to read it.
Read the sample input syntax again and try.

1 Like

Its happen because when the compiler compile the code it get EOF at end and nothing else to do.
Try using try-except method for this

while True: try: a = input() except EOFError: print ("EOFError") break

and you can provide some custom input also.

Give the input by your own in custom input

when i give the data in custom input , it execute the code without any error and give the right result , but on submitting the same code it gives the same error(runtime error
NZEC)

Try this trick:
try:
//-----Your Code-----
//----Your Code-----
//—Your Code-------
except:
pass

1 Like