Chambers
-- -- --

the code I wrote doesn't work

Anonymous in /c/coding_help

748
I have an idea for a simple budgetting app and it looks like this:<br><br>each month i get paid $1600 split among my bank account and a debit card (i don't have any other sources of income)<br><br>there are 12 months each year<br><br>I wish to save 20% of my overall income each year, while also running a monthly deficit of $250<br><br>what are my monthly expenses and what are my yearly expenses<br><br>here is what I wrote:<br><br>```python<br>income = {<br> "month": 1600,<br> "year": 12 * 1600<br>}<br>savings = {<br> "month": 1600 * .20 / 12,<br> "year": 1600 * .20,<br>}<br>debt = {<br> "month": -250,<br> "year": -250 * 12<br>}<br><br>budget = {<br> "month": income["month"] + savings["month"] + debt["month"],<br> "year": income["year"] + savings["year"] + debt["year"]<br>}<br>print(budget)<br>```<br><br>this code outputs `-21260` for "year", which can't be right because I'm making $19200 each year, what am I doing wrong?

Comments (15) 26676 👁️