Hey everyone, I have written a code that figures out a users total montly expenses. I have it working except for the fact that it does not add up their cumulative entries. For example, the code ask the user to enter their net montly income then an expense name and the cost of this expense it then ask them if they have another expense to enter if they hit no it calculates their monthly expenses by subtracting their net income from the expense and returns what money they have left over after expenses. If the user hits yes the program as them to enter an expense name and its cost. What I want to figure out is how to add up multiple expenses so that the user can keep entering as many expenses as they want and the program will properly calculate their total expenses and return what they have left over. Here is the code I have so far.
Thanks for your help.
Thanks for your help.
Code:
# Monthly Cost Calculator print \ ''' Welcome to Monthly expense Calculator 1.0. This program adds up your total montly expenses subtracts them from your total montly income and lets you know what your total expenses are every month. ''' tk_home_pay=float(raw_input("Please enter your total monthly take home pay: ")) reply='y' while(reply!='n'): exp=raw_input("Please enter the name of the expense: ") cost=float(raw_input("Please enter the cost of this expense: ")) reply=raw_input("Do you want to enter another expense y/n ? ") if (reply == 'y'): continue tot_exp=tk_home_pay-cost print "Your totaly net income is:", tot_exp
Comment