Hello
I am trying to create this program for a uni assignment. I cannot get it to add the expenses to the accumulator I have set. Would you mind having a look and letting me know if I have something in the wrong place or indented incorrectly. Perhaps I am missing something. There could be other things wrong but I need to fix this first and then I can focus on the next thing. I have difficulty trying to fix lots of things at once so if you could just comment on the problem and I will ask again if I can't work out the next problem I have. I like to have a go myself first. J My code is: """This program is to calculate if the user is over or under budget for the month""" def main(): # Create an accumulator total_expense = 0.0 # Ask user for the monthly budget budget = float(raw_input('Enter the amount of your budget for the month: $')) # Calculate a series of expenses expense = float(raw_input('Enter your first expense $')) # Accumlate expense total_expense = total_expense + expense # Continue processing as long as the user # does not enter 0 while expense != 0: #Get another expense expense = float(raw_input('Enter the next expense or 0 to finish $')) #Calculate surplus surplus = budget - total_expense #Display results print 'Your total expenses for the month $', total_expense print 'Your surplus amount after expenses $', surplus # Call the main function. main() Thank you.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor