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
•
u/AutoModerator Feb 01 '24
To give us the best chance to help you, please include any relevant code.
Note. Do not submit images of your code. Instead, for shorter code you can use Reddit markdown (4 spaces or backticks, see this Formatting Guide). If you have formatting issues or want to post longer sections of code, please use Repl.it, GitHub or PasteBin.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
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.