CanadaTechLife

Python Budget Tracker Script

Apr 22nd, 2026
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. Here is a straightforward, functional Python script to help you track your spending. It uses a dictionary to store categories and their respective totals, making it easy to see where your money is going.
  2.  
  3. # Simple Personal Budget Tracker
  4.  
  5. # Categories: groceries, transport, entertainment, dining, etc.
  6. budget = {
  7.     "groceries": 0.0,
  8.     "transport": 0.0,
  9.     "entertainment": 0.0,
  10.     "dining": 0.0,
  11.     "other": 0.0
  12. }
  13.  
  14. def add_expense():
  15.     print("\nAvailable: groceries, transport, entertainment, dining, other")
  16.     category = input("Enter category: ").lower()
  17.    
  18.     if category in budget:
  19.         try:
  20.             amount = float(input(f"Amount for {category}: "))
  21.             budget[category] += amount
  22.             print("Successfully added!")
  23.         except ValueError:
  24.             print("Error: Please enter a number.")
  25.     else:
  26.         print("Category not found.")
  27.  
  28. def show_balance():
  29.     print("\n--- Current Spending ---")
  30.     for cat, total in budget.items():
  31.         print(f"{cat.capitalize()}: ${total:.2f}")
  32.     print(f"Total: ${sum(budget.values()):.2f}")
  33.  
  34. while True:
  35.     choice = input("\n1. Add Expense | 2. Summary | 3. Exit: ")
  36.     if choice == '1':
  37.         add_expense()
  38.     elif choice == '2':
  39.         show_balance()
  40.     elif choice == '3':
  41.         break
  42.     else:
  43.         print("Invalid choice.")
Advertisement
Add Comment
Please, Sign In to add comment