I have an assertion error and i can’t understand what is the problem:
assertionerror:
‘Perc[211 chars]----- \n B F E \n u o n \n [168 chars] \n’ !=
'Perc[211 chars]-----\n B F E \n u o n \n s [163 chars] t ’
I understand i have to modify some spaces but i can’t find the right tweaking, did i miss something else in my code?
def create_spend_chart(categories):
total_spent = sum(category.spent for category in categories)
percentages = [int(category.spent / total_spent * 100 // 10) * 10 for category in categories]
chart = "Percentage spent by category\n"
for i in range(100, -1, -10):
row = f"{i:>3}|"
for percent in percentages:
if percent >= i:
row += " o "
else:
row += " "
chart += row + " \n"
chart += " " + "-" * (len(categories) * 3 + 1) + " \n"
max_len = max(len(category.category) for category in categories)
for i in range(max_len):
row = " "
for category in categories:
if i < len(category.category):
row += category.category[i] + " "
else:
row += " "
chart += row.rstrip() + " \n"
return chart