{}
run-icon
main.py
# Simple Personal Finance Tracker (No File Storage) transactions = [] balance = 0 # Function to add an income or expense def add_transaction(): global balance type_ = input("Type (income/expense): ").lower() amount = float(input("Amount: ")) description = input("Description: ") if type_ == "income": balance += amount elif type_ == "expense": if amount > balance: print("āŒ Not enough balance!") return balance -= amount else: print("Invalid type! Use 'income' or 'expense'.") return transactions.append({"type": type_, "amount": amount, "description": description}) print("āœ… Transaction added!") # Function to view transactions def view_transactions(): print("\nšŸ“œ Transaction History:") for i, tx in enumerate(transactions, 1): print(f"{i}. {tx['type'].capitalize()} - ā‚¹{tx['amount']} ({tx['description']})") print(f"\nšŸ’° Current Balance: ā‚¹{balance}") # Main loop while True: print("\nšŸ“Š Personal Finance Tracker") action = input("Choose: (add/view/exit): ").lower() if action == "add": add_transaction() elif action == "view": view_transactions() elif action == "exit": print("šŸ‘‹ Goodbye!") break else: print("Invalid option, try again!")
Output