A menu-driven, console-based expense tracker built entirely with Core Python. Users can log expenses, review their spending history, and see a running total β all backed by a simple, dependency-free accumulator pattern.
π Built as Project 2 of the Python Programming Internship at DecodeLabs, focused on data accumulation, state management, and defensive input handling in backend logic.
The Expense Tracker simulates the core of a real financial ledger: numbers
come in one at a time, get validated, and get added to a running total that
persists for the life of the session. It's a small program, but it's built
around the same fundamental pattern (total += new_value) that powers much
larger financial and analytics systems.
The entire application lives in a single, well-documented Python file and uses nothing beyond the standard language β no databases, no file storage, no third-party packages.
| Program | Python Programming Internship |
| Organization | DecodeLabs |
| Project | Project 2 β Expense Tracker |
| Focus Area | Data accumulation & stateful console logic |
| Constraint | Core Python only (no external libraries, no persistence) |
- Add Expense β enter an amount and add it to the running total using
the accumulator pattern (
total += new_expense). - View Expense History β see every expense recorded during the current session, numbered in the order it was entered.
- View Total Expenses β see the total number of expenses logged and the running total spent.
- Delete Last Expense β remove the most recently added expense and automatically subtract it back out of the total.
- Reset Expense Tracker β clear all recorded expenses and reset the total to zero, with a yes/no confirmation step to prevent accidental data loss.
- Exit β a sentinel-controlled, clean shutdown of the program.
Built-in input safety (every feature is protected by this):
- Rejects non-numeric input instead of crashing.
- Rejects negative expense amounts.
- Rejects empty input and zero-value amounts.
- Rejects out-of-range or non-numeric menu selections.
- Gracefully handles
Ctrl+C/Ctrl+D(KeyboardInterrupt/EOFError) instead of throwing a raw traceback.
- Language: Python 3.x
- Libraries: None β Core Python only (
input(),print(), lists, loops, conditionals, functions) - Storage: In-memory only (a Python list), scoped to the current session
- Interface: Command-line / console
Expense_Tracker_Project/
βββ main.py # Complete application source code
βββ README.md # Project documentation (this file)
βββ LICENSE # MIT License
βββ .gitignore # Python-specific ignore rules
βββ PROJECT_STRUCTURE.md # Detailed explanation of every file
βββ screenshots/ # Real terminal screenshots of the app
βββ home.png
βββ add-expense.png
βββ expense-history.png
βββ total-expenses.png
βββ delete-expense.png
βββ reset-tracker.png
βββ invalid-input.png
βββ negative-expense.png
βββ exit.png
Clone the repository:
git clone https://github.com/PawanChoudhary0607/Python-Expense-Tracker.git
cd Python-Expense-TrackerNo dependencies to install β the project runs on the Python standard library alone.
Requirements: Python 3.x
python3 main.pyOn Windows:
python main.pyStart
β
βΌ
Display Menu (1-6)
β
βΌ
Read & Validate Menu Choice
β
βββ 1 β Add Expense β Validate amount β total += amount
βββ 2 β View History β Print all recorded expenses
βββ 3 β View Total β Print count + running total
βββ 4 β Delete Last Expense β Remove last item β total -= amount
βββ 5 β Reset Tracker β Confirm β Clear list β total = 0
βββ 6 β Exit β Print goodbye message β break loop
β
βΌ
Loop back to Menu (while True)
Welcome to the DecodeLabs Expense Tracker!
==============================
EXPENSE TRACKER
==============================
1. Add Expense
2. View Expense History
3. View Total Expenses
4. Delete Last Expense
5. Reset Expense Tracker
6. Exit
==============================
Enter your choice (1-6): 1
Enter expense amount: 250
Expense of 250.00 added successfully.
Running Total: 250.00
Building this project reinforced several core backend-engineering concepts:
- The accumulator pattern β how
total = total + new_valueforms the backbone of any system that processes a continuous stream of numeric data (ledgers, counters, running statistics). - State vs. amnesia in loops β the importance of initializing state outside a loop so it persists across iterations, rather than resetting it on every pass.
- Defensive coding β treating all user input as untrusted by default, validating type, sign, and emptiness before it ever reaches business logic.
- Sentinel-controlled program flow β using a dedicated exit value to
cleanly break out of an otherwise infinite
while Trueloop. - Separating logic from display β keeping calculation (the "model") distinct from what gets printed to the user (the "view"), even in a single-file script.
- Add expense categories (e.g., Food, Travel, Utilities).
- Persist expenses between sessions (file or database storage).
- Add date/timestamp tracking for each expense.
- Add a monthly or weekly spending summary.
- Add CSV export for use in spreadsheets.
Pawan Choudhary B.Tech CSE (AI & ML) Python Programming Intern @ DecodeLabs
GitHub: github.com/PawanChoudhary0607
This project is licensed under the MIT License.