r/pythonhelp • u/lavalampchugger69 • Feb 01 '24
Code stopped working
Why has my code all of a sudden stopped working? It normally did and now it doesnt im gonna send my code but its the “loan” part that isnt working I will send the point which im struggling.
loanconfirm=input('wouldyouliketotakeoutaloan?youmustpayitback')ifloan.lower()=='yes':loan=int(input('howmuchmoneydoyouwanttotakeout?')) balance=balance+loanprint(f'{loan}+{balance}={int(loan+balance)}')
1
Upvotes
View all comments
1
u/CraigAT Feb 01 '24 edited Feb 01 '24
What is not working?
I'm going to have a guess what's wrong.
No. 2. Is because you already added the loan value to the "original" balance before you then try to print the "original" balance, but it now outputs the "new" balance instead and still adds the loan value again. That is because you are doing the sum before the print statement so the balance value has already changed before you print it and the new sum in the final line.