amount=int(input())
balance=initial=float(input())
if amount%5==0 and amount+0.5<initial:
balance=initial-amount-0.5
print(balance)
What is wrong with this code, i am getting a run time error .But i got output in my compiler
amount=int(input())
balance=initial=float(input())
if amount%5==0 and amount+0.5<initial:
balance=initial-amount-0.5
print(balance)
What is wrong with this code, i am getting a run time error .But i got output in my compiler
in Python input() reads the whole line which also contains the space character. Do it like this.
cash, balance = map(float, input().split())
if(cash%5 != 0 or cash+0.5 > balance):
print(balance)
else:
print("{:.2f}".format(balance-cash-0.5))
bro still getting run time error.
You might have forgot to case those to int
as they are casted to float
as of now
w, b = map(float, input().split())
if w+0.5<=b and w %5==0: b=b-(w+0.5)
print("%.2f" % b)