Have Been Getting Wrong Answer Even Though Code Seems Correct

Im a beginner in python and tried to solve the ATM problem ATM PROBLEM . Even Though My Code Is Giving The right output , my submission was graded as ‘Wrong Answer’
Please Help

withdraw,balance = input('Enter Withdrawal And Balance').split()
withdraw = int(withdraw)
balance = float(balance)
if withdraw>0 and withdraw+0.5<balance and withdraw%5==0:
    new_bal = balance - withdraw - 0.5
    print('{:.2f}'.format(new_bal))
else:
    print('{:.2f}'.format(balance))

Remove ‘Enter Withdrawal And Balance’ and just write input().split() . Also withdraw+0.5 will be less than or equal to balance (withdraw+0.5<=balance)

Got it ,Thank you . So should i avoid writing ‘Enter Withdrawal And Balance’ type of statements in the input function in all the problems i solve in the future?

yes, you only need to print the desired output so you should avoid writing these statements

2 Likes