Build a Budget App Project - display not accepted

Tell us what’s happening:

why doesn’t it like my final chart? It looks totally corrrect to me!

Your code so far

class Category:
    def __init__(self,name):
        self.ledger=[]
        self.budget=0
        self.name=name
        self.percent=0

    def deposit(self,amt,descr=''):
        self.budget+=amt
        self.ledger.append({"amount":amt, "description":descr})

    def withdraw(self,amt, descr=''):
        if self.check_funds(amt):
            self.deposit(amt*(-1),descr)
            return True
        else:
            return False

    def get_balance(self):
        return self.budget

    def check_funds(self, amt):
        return self.budget>=amt


    def transfer(self,amt,dest): #xfer out
        descr="Transfer to %s" % dest.name 
        if self.check_funds(amt):
            self.budget-=amt
            self.ledger.append({"amount":amt*(-1), "description":descr})
            dest.deposit(amt,f"Transfer from {self.name}")
            return True
        else:
            return False
        
        

    def __str__(self):
        string=''
        title=self.name.center(30,'*')
        string+=title
        string+='\n'

        for item in self.ledger:
            descr=item["description"]
            amt=item["amount"]
            string+=f'{descr[0:23]:23}{amt:7.2f}' 
            string +='\n' 
        string += 'Total: '
        string+=str(self.budget)
        return string

def create_spend_chart(categories):
    array=['']*14
    array[0]='Percentage spent by category'
    array[1]='100|'
    for i in range(2,11):
        array[i]=(' '+str(110-10*i)+'|')
    array[11]='  0|'
    array[12]='    '
    array[12]+='---'*(len(categories))+'-'
    maxname=0
    for cat in categories:
        maxname=max(maxname,len(cat.name))
    for i in range(maxname-1):
        array.append('    ')

    totspent=0
    for cat in categories:
        spent=0
        for item in cat.ledger:
            if ('Transfer' not in item["description"]) and (item["amount"]<0):
                spent-=item["amount"]
        cat.percent=spent
        totspent+=spent
    for cat in categories:
            cat.percent=10*cat.percent/totspent
    for cat in categories:
            print(cat.name,' ',cat.percent)
    #sort categories by cat.percent
    categories.sort(reverse=True,key=lambda cat:cat.percent)
    for i in range(11):
        row=11-i
        for cat in categories:
            if (cat.percent)>=(i):
                array[row]+=' o '

    
    array[13]='    '            
    for i in range(maxname):
        for cat in categories:
            if len(cat.name)>i:
                array[13+i]+=(' '+cat.name[i]+' ')
            else:
                array[13+i]+='   '
    array=['']+array
    print('\n'.join(array))        
    return '\n'.join(array)


food = Category("Food")
food.deposit(60, "deposit")
food.withdraw(60, "groceries")

clothing = Category("Clothing")
clothing.deposit(20, "clothing")
clothing.withdraw(20, "clothing")

auto=Category("Auto")
auto.deposit(60,"car")
auto.withdraw(10,"car")

print(food)
create_spend_chart([food,clothing, auto])

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36

Challenge Information:

Build a Budget App Project - Build a Budget App Project

Check the devtools console (F12) for a more detailed error message.

That didn’t help; it seems to be saying I have 2 extra characters (pyodide.asm.js:9 AssertionError: '\nPercentage spent by category\n100| [385 chars] ’ != 'Percentage spent by category\n100| [383 chars] t ') but I’m not sure where. I also see these weird messages:
pyodide.asm.js:9 - 70| o
pyodide.asm.js:9 ? —
pyodide.asm.js:9 + 70| o
pyodide.asm.js:9 ? +++
pyodide.asm.js:9 - 60| o
pyodide.asm.js:9 ? —
pyodide.asm.js:9 + 60| o
pyodide.asm.js:9 ? +++
pyodide.asm.js:9 - 50| o

Look at it in three backticks so we can see the spacing clearly and compare the two lines:

AssertionError: 
'\nPercentage spent by category\n100| [385 chars] '
!= 
'Percentage spent by category\n100| [383 chars] t '

You can see the differences clearly this way. Your line is first, the expected output is second.

Your output starts with a \n, which it shouldn’t