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


[closed] 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: 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))

asked 17 Dec '13, 20:44

ks2bmallik's gravatar image

accept rate: 22%

closed 19 Dec '13, 18:58

kcahdog's gravatar image


The question has been closed for the following reason "The question is answered, right answer was accepted" by kcahdog 19 Dec '13, 18:58

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.


answered 17 Dec '13, 21:39

kcahdog's gravatar image

accept rate: 14%

thanx buddy..!! :D


answered 19 Dec '13, 09:47

ks2bmallik's gravatar image

accept rate: 22%

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 17 Dec '13, 20:44

question was seen: 2,701 times

last updated: 19 Dec '13, 18:58