Skip to content

Commit e4b5fb2

Browse files
authoredAug 22, 2023
Update expense_tracker.py
1 parent acdad94 commit e4b5fb2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed
 

Diff for: ‎expense_tracker.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,14 @@ def refresh_list(self):
149149
def update_total_label(self):
150150
total_expenses = sum(float(expense[0]) for expense in self.expenses)
151151
self.total_label.config(text=f"Total Expenses: USD {total_expenses:.2f}")
152-
152+
153153
def save_expenses(self):
154154
with open("expenses.csv", "w", newline="") as csvfile:
155155
writer = csv.writer(csvfile)
156-
for expense, item, category, date in self.expenses:
157-
writer.writerow([expense, item, category, date])
156+
column_headers = ["Expense Amount", "Item Description", "Category", "Date"]
157+
writer.writerow(column_headers)
158+
for expense in self.expenses:
159+
writer.writerow(expense)
158160

159161
def show_expenses_chart(self):
160162
category_totals = {}
@@ -176,4 +178,4 @@ def show_expenses_chart(self):
176178

177179
if __name__ == "__main__":
178180
app = ExpenseTrackerApp()
179-
app.mainloop()
181+
app.mainloop()

0 commit comments

Comments
 (0)
Please sign in to comment.