Your program reads messy text and reports on it.
That is a specific claim about what the eight lessons of this part put in your hands. Run your tracker below. If you worked through the exercises in this part, it opens with your own version. If not, it opens with the finished Part 3 starter.
The second line of the report shows the current month. The third shows how many days are left in it. Both come from today's date, so they keep up with the calendar without you touching the code.
What your program can do
At the end of Part 2, your expenses were bare numbers. Now your tracker knows what each one was for.
Each expense is a record: a dictionary with an item, a category and an amount. The records sit together in one list. A loop pulls their amounts out for sum, max, min and count_over. A separate dictionary gives each category its own budget. Your tracker adds up spending per category in a loop, then checks each total against its budget and marks the ones that are over.
It no longer needs those records typed out one by one. It builds them from receipt_text, a block of text with one expense per line. It splits each line at the commas, strips the spaces, and lowercases the category. An amount that int cannot convert, like ₦1000, no longer crashes the report. Your tracker catches the ValueError, skips that line, and lists it under Skipped lines: at the end.
It slices the list to show your latest three expenses. It sorts a copy of the list by amount, biggest first, to show your top three. And it imports from two modules that come with Python. date, from the datetime module, gives it today's date. calendar tells it how many days this month has.
Everything from Parts 1 and 2 is still at work underneath: the f-strings, the three-way status, the savings loop and your own functions.
What it cannot do yet
Your receipt text is still typed into the code. To log a new expense, you open main.py and add a line to receipt_text by hand. Your tracker cannot ask you for an amount while it runs. It cannot read a file of receipts either.
It also saves nothing. When a run ends, every list and total it built is gone. The next run builds them again from the code.
Those limits come from where it runs. This sandbox gives your program no keyboard input, and no way to reach the files on your computer. That is why receipt_text has been standing in for a file all along.
What comes next
First, the capstone. You will build a different program: a class grade report. You start with the class results already typed in, and nothing else: no program code, and no steps to follow. It uses the same tools as your tracker: records, functions that return values, decisions, loops, sorting, and try / except. You have written every one of those already. The capstone checks whether they travel with you.
Then, Python on your own computer. Your tracker is ordinary Python. It does not need this site to run. Here is how to run it on your own machine:
- Install Python 3 from python.org. Pick the download for your system. Most Linux systems have Python 3 already.
- Press DOWNLOAD on your tracker above. It saves the code as
main.py, usually in your Downloads folder. If an oldermain.pyis there, delete it first, or your browser names the new onemain (1).pyor similar. - Open a terminal, a window where you type commands. On Windows, use PowerShell or Command Prompt. On macOS and Linux, use the Terminal app.
- Move the terminal into the folder that holds
main.py. If that is your Downloads folder, typecd Downloadsand press Enter. - Type
python main.pyand press Enter. On macOS and Linux, typepython3 main.pyinstead. On Windows, ifpythonis not found, typepy main.py.
Your report prints in the terminal. Three things work differently there:
- Output appears line by line, as each
printruns. In the sandbox, it all appears when the run finishes. - There is no 5-second guard. A loop that never ends keeps going until you press Ctrl+C.
input()reads what you type, andopen()reads files. Your receipt text could come from a real file instead of a block in your code.
Those two, input() and files, are the next things to learn there. Both hand your program text, the same kind of text as receipt_text. You already know how to split it, clean it and convert it.