Python Budget App - hints and tips

I just completed the Python Budget App, and it was quite a struggle. So I thought I’d share a few tips with you that you might find helpful.

  1. I was confused by the entire ‘percentage’ thing. Percentage of what? Turns out, you’re supposed to add the withdrawals in all categories (= 100 %), and then provide the withdrawals in one category as a percentage of this total amount of withdrawals. That is, if the combined withdrawals in all categories add up to 200, and the withdrawals in, say, the Food category amount to 20, the percentage is 10. This was helpfully explained to me by user ‘SanAntonik’.

  2. If you look closely at the spacing in the example output provided in the readme file, you’ll notice there is an extra blank space at the end of each line (row)! For instance, behind the “A” of “Auto”, there are two blank spaces, not just one. There is also one extra “-“ at the end of the “----” row. If your output looks like the model output but still fails the tests, this might be the reason. (took me while to figure this out)

  3. The create_spend_chart takes a list of categories as an argument. Note that these categories are not passed as strings (e.g. [“Food”, “Clothes”]) but as the category objects created by the Category class.

  4. Regarding the printing of the budget object: There is a dedicated method for printing the string representation of an object (https://www.journaldev.com/22460/python-str-repr-functions).

Hope you find this hepful. Feel free to add other tips in the comments.

7 Likes

Yeah I am working on this right now and getting the spacing right is a struggle.

If I add print(actual) and print(expected) to the test_module for the create_spend_chart function they look identical. Judging from the unittest output I have an extra space somewhere on the last line but it isn’t easy to determine where from that output.

I was scratching my head wondering how I was going to print that object, thanks a million for the link

i came across exactly those issues and this post sums up very well crucial points on completing the challenge. Would be great if they can be hinted in the project description