# 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!")