please help me i m stuck …i am getting a run time error here’s the code :
with_draw,balance =input().split()
with_draw=int(with_draw)
balance=float(balance)
if with_draw>balance or with_draw<0 or with_draw%5!=0 or balance-with_draw<.5 or balance< 0:
print(balance)
else:
balance-=with_draw
balance-=0.5
print(balance)
Problem is with the first line of your code.
you might want to use raw_input() and then split() input.
i.e. raw_input().split()
this will return string, so convert it into float
like this float,raw_input().split()
, now you want to assign these values to respective variables so use map
So finally you have to use with_draw,balance = map(float,raw_input().split())
I think that will do, (didn’t check your logic though, there are a lot of unnecessary conditions within if
)
P.S.: you’ve not specified which Python version you are using 2.x or 3.x, so I assumed it to be 2.x,
raw_input()
does not exist in Python 3.x, actually you can use input()
instead of raw_input
in Python 3.x, you might want to go through actual syntax for Python 3.x over internet.