Help for Budget App. I don't know what's wrong with the result

Here’s the code. I don’t know why the result says the spacing is wrong

def create_spend_chart(categories):
    spending = [round(Category.expense,2) for Category in categories]
    heading = "Percentage spent by category\n"
    percent_chart = ''
    
    total = round(sum(spending), 2)

    percentage_list =[round((((spent/total)*10)//1)*10) for spent in spending]

    for number in range(100,-1,-10):
        percent_chart += str(number).rjust(3) + '|'
        for percentages in percentage_list:
            if percentages >= number:
                percent_chart += ' o '
            else:
                percent_chart += '   '
        percent_chart += chr(10)
    combined = heading + percent_chart
    
    footer = "    " + ("-" * ((len(categories)*3) + 1))

    the_categories = [x.category for x in categories]

    max_length = 0
    for x in the_categories:
        if len(x) > max_length:
            max_length = len(x) 
    categs = [category.ljust(max_length) for category in the_categories]

    for category in zip(*categs):
        footer += "\n" + "    " + "".join(map(lambda s: s.center(3), category)) + " \n"
    return (combined + footer).rstrip()

Here’s the error message:

I’ve solved it now. Sorry to bother.

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