Budget App / Python

Tell us what’s happening:
Even though the output is similar to what the assignment demands, I can’t seem to get the problem with the extra spaces.
Here’s the link: https://repl.it/@trifonas/boilerplate-budget-app-1#budget.py
I’ve searched around in the previous topics and I feel like many have faced this problem, but I can’t find a solution for my code.
Thanks to everyone in this forum, this is the third project I’m asking help for.
Your code so far

def create_spend_chart(categories):
    chart = 'Percentage spent by category\n'
    total = sum(x.get_balance() for x in categories)
    percentages = [(x.get_balance()/total)//0.01 for x in categories]

    for x in range(100, -10, -10):
        chart = chart + str(x).rjust(3, " ") + "|"
        for y in percentages:
            if y >= x:
                chart = chart + " o "
            else:
                chart = chart + "   "
        chart = chart + " \n"
    chart = chart + "    " + "-"*len(percentages)*3 + "-\n"
    maxLength = max(len(x.name) for x in categories)
    for x in range(maxLength):
        chart = chart + "    "
        for y in categories:
            if x < len(y.name):
                chart = chart + " " + y.name[x] + " "
            else:
                chart = chart + "   "
        chart = chart + " \n"
    return chart.rstrip() +"  "

The output

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0.

Challenge: Budget App

Link to the challenge:

Well for a start, look at your output - you will notice that your “total” is not a number.
Next thing I notice in your output is that the barchart is wrong.
Mine has 7 o for food, 4 clothing, 3 auto. Yours has 5 food, 1 clothing and 6 auto.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.