HS08TEST (ATM) Python Runtime (NZEC) Error

I am new to python, and trying my luck on some easy problems first. I have checked my source code for various inputs (problem code HS08TEST, link: http://www.codechef.com/problems/HS08TEST) but unable to find any problem but still it shows runtime error on submission. Please help guys. Here’s my code:

import sys
withdraw, balance = map(float, sys.stdin.readline().split())
print ("%.2f" % balance) if int(withdraw)%5 != 0 or balance < (withdraw + 0.5) else ("%.2f" %     (balance - withdraw - 0.5))

The sys.readline() reads the entire line so all characters on the line including the next line character “\n” are read which cannot be converted to float and causes NZEC. Just change it to sys.stdin.readline().strip().split()) to remove the “\n” and it works fine. here is the accepted version.

1 Like

thanx buddy…!! :smiley:

//