Budget app chart help

I’m confused as to why I’m failing this test, it seems to be an issue with the percentages calculations but I have no ideas whats wrong with them

https://replit.com/@th0mas-w/FCC-budget-app#budget.py

def create_spend_chart(categories):
    total = 0
    final = "Percentage spent by category\n"
    for i in categories:
        total += i.balance
    final += f"100|\n"
    for i in range(90,-10,-10):
        if i == 0:
            final += " "
        final += f" {i}|"
        for j in categories:
            rounded = round(j.balance / 10)*10
            if rounded/total * 100 >= i:
                final += " o "
            else:
                final += "   "
        final += "\n"
    final += "    " + "-" * ((len(categories) * 3) + 1)
    fails = char = 0
    while fails < len(categories):
        fails = 0
        final += "\n     "
        for i in categories:
            try:
                if fails > 0:
                    final += "   "
                final += i.name[char] + "  "
            except:
                fails += 1
        char += 1

    return final

Well the error doesn’t exactly look helpful… anyway, let’s take and realing it:

'Perc[25 chars]n100|\n 90|         \n 80|         \n 70|     [342 chars]    ' 
!= 
'Perc[25 chars]n100|          \n 90|          \n 80|         [349 chars] t  '

Seems like you are missing some spaces both right after the 100, as well is in every line:

\n 90|         \n 80|         \n 70|     [342 chars]    ' 
\n 90|          \n 80|         [349 chars] t  '

Hi, thanks for the help. I’ve made some tweaks and the spacing errors seem to be fixed. However, It’s now giving me an error which looks like it’s expecting a bar to reach a percentage that my program isn’t reaching. I’ve included the data that I believe its using below and I’ve done the percentage calculations myself and I think that they should all be at 30% but the tests are showing one of them to be at 70?

***********Business***********
deposit                 900.00
                        -10.99
Total: 889.01
*************Food*************
deposit                 900.00
                       -105.55
Total: 794.45
********Entertainment********
deposit                 900.00
                         -33.4
Total: 866.6

I don’t follow what you did calculate there?
The test case you showed shows an entry with 105 of roughly 150 total, which is over 60%.

I’m confused, where are you getting the numbers 105 and 150 from?

From the code you posted?
Food is 105.55 spent, and total spent on all 3 categories together is roughly 150.

Oh I’m so dumb, the whole time I thought the chart was meant to show the totals

lol yeah it happens ^^
So I guess you can do it now, just a little heads-up: the task wants to round in a specific way.
I didn’t check you code, but this is a common error.

Ok thank for the help