Hi, I’m having trouble in last step of this project.

At first I thought I should sort the categories by the overall spends…but now I think I shouldn’t…

So, now…I can’t see where I’m missing

===== Here it is my function:

def create_spend_chart(categories):

```
N = len(categories)
total = 0.0
total_cat = []
for category in categories:
t_cat = 0.0
for ledger in category.ledger:
if ledger['amount'] < 0: # negative only
t_cat += ledger['amount']
total += ledger['amount']
total_cat.append(t_cat)
percentage = []
for i in range(N):
perc = []
for j in range(12): # 0 1 2 .. 11
if int(10*total_cat[i] / total ) >= j:
perc.append(' o')
else:
perc.append(' ')
percentage.append(perc)
string = 'Percentage spent by category\n'
for j in range(10,-1,-1):
string += f'{10*j:>3}|'
for i in range(N):
if i < (N-1):
string += f'{percentage[i][j]} '
else:
string += f'{percentage[i][j]} ' ##
string += '\n'
string += ' '*4 + '-'*((3*N) + 1) + '\n'
maximo = len(categories[0].category)
for i in range(N):
if maximo < len(categories[i].category):
maximo = len(categories[i].category)
for j in range(maximo):
string += ' '*5
for i in range(N):
if j < len(categories[i].category):
string += str(categories[i].category)[j]
else: string += ' '
if i < (N-1):
string += ' '
if j != (maximo -1):
string += ' \n' ####
return string
```

======