# Budget App-Scientific computing with Python

I’m not understanding what’s wrong here in create_spend_chart:

``````def create_spend_chart(categories):
categories_withdrawals = [[transact['amount'] for transact in category.ledger if transact['amount'] < 0] for category in categories]
total_withdrawals = [sum(withdrawals) for withdrawals in categories_withdrawals]
total_balances = [x.get_balance() - y for x,y in zip(categories, total_withdrawals)]
percentage_spent = [abs(x) / y for x, y in zip(total_withdrawals, total_balances)]
#print(total_balances)
#print(total_withdrawals)
#print(percentage_spent)
x = ["Percentage spent by category"]
# constructing labels of bar chart
for i in range(110,0,-10):
x.append((str(i-10)+'|').rjust(4))

# filling the bar chart according to percentage spent
for i in range(1,12):
for j in range(len(categories)):
if percentage_spent[j] * 100 > (11-i)*10:
x[i] += ' o '

x.append('    ' + '--'*(2 + len(categories)))
# constructing category name
#list of categories names
names = [name.category_name for name in categories]
vertical_names = zip_longest(*names, fillvalue = ' ')
for row in vertical_names:
x.append('     ' + '  '.join(list(row)))
print(x)
for row in x[1:]:
print(row)
``````