Python NZEC Runtime error CodeChef IDE

My Code for the Beginner’s ATM problem in Python 2.7 :

X,Y=raw_input().split(’ ‘) #Comment :X,Y=input().split(’ ') or X,Y=raw_input().split( )
X=int(X)
Y=float(Y)
if(X<Y and X%5==0):
print("%.2f" %(Y-X-0.50))
elif(X<Y and X%5!=0):
print("%.2f" %Y)
else:
print("%.2f" %Y)

My code for Beginner’s ATM problem in python 3.6 :

import sys
line=sys.stdin.readline()
X,Y=line.split(’ ')
X=int(X)
Y=float(Y)
if(X<Y and X%5==0):
print("%.2f" %(Y-X-0.50))
elif(X<Y and X%5!=0):
print("%.2f" %Y)
else:
print("%.2f" %Y)

Any combination of input() / raw_input() or sys.stdin doesn’t seem to work on the codechef ide where as all of them work on python compiler anywhere else. Can anyone tell me how is everyone else submitting solutions for python problems on codechef, because I am not able to since few days.

1 Like

Hi @vijayjindal,

This is the line which has a mistake.
The .split() function makes a list.
So, ideally, you must take input like this:

inp=raw_input().split()
X=int(inp[0])
Y=float(inp[1])

Else, you can use the map() function:

X,Y=map(int, raw_input().split())
Y=float(Y)

Cheers
Aadarsh…

Hi Aadarsh,
Thank you for the response.
But I have tried all combinations.
Just now, I tried using sys.stdin.readlines() function.
CodeChef mentions that the input by the IDE is a stdin.
But, when I use this function, It doesn’t give me any input. The input from CodeChef IDE is null.


import sys
lines = sys.stdin.readlines()
print(lines)

The above three lines of code give this as the output : [ ]
which is null list.
Does it mean that there is no input from the IDE?
The use of input, raw_input gives EOF error.

I tried all combinations of raw_input, spilt and yes the one you suggested.
Is there anything else, that might seem to work.

Thank you.

@vijayjindal,
Sorry for the late reply.
“stdin” refers to standard I/O. You can use:

inp=raw_input() #Only in Python2
inp=input() #Can be used for taking one number input in Python2 (or) input in Python3

Else, you can even use for this question:

import sys
line=sys.stdin.readline().split()
X=int(X)
Y=float(Y)
#print (line) 

The custom input column should be checked and copy paste the sample input provided by codechef for testing. If you don’t check it, the ide will return a EOF error.

The code I suggested in the above post, was written for Python2.7. Check these out and let me know if you got AC.

PS: You can check out my submission in Python2.7, as a last resort. (If you are stuck)
My code

Cheers
Aadarsh…