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

×

atm problem: runtime error python 2.7

Question: https://www.codechef.com/problems/HS08TEST

my code:

cash=int(raw_input())

balance=float(raw_input())

if cash+0.5<balance and cash%5==0:

    balance= balance-cash-0.50

    print balance

else:

print balance

but it is running in my compiler and in online compiler showing runtime error can any one please rectify it

asked 30 Dec '18, 12:44

tiwarivikas461's gravatar image

0★tiwarivikas461
52
accept rate: 0%

edited 30 Dec '18, 12:46


In the question , we can see that input is in the same line. But in your program input is in two different lines.instead of:

cash=int(raw_input())

balance=float(raw_input())

try:

cash,balance=raw_input().split()

cash = int(cash)

balance = float(balance)

link

answered 30 Dec '18, 12:55

ppatelhemant's gravatar image

1★ppatelhemant
182
accept rate: 50%

edited 30 Dec '18, 12:57

raw_input() takes input as a string. So, you need to split it w.r.t space and cast the data type you need.

my solution link

link

answered 30 Dec '18, 12:56

charan9948's gravatar image

4★charan9948
161
accept rate: 100%

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:

×678
×429
×190

question asked: 30 Dec '18, 12:44

question was seen: 86 times

last updated: 30 Dec '18, 12:57