My graph looks correct but for some reason it says I’ve 804 extra characters. I’d be glad for any help rendered. Thanks
see my code:
def create_spend_chart(categories):
total_spending = sum([category.spendings for category in categories])
percentage_spending = [round(category.spendings / total_spending * 100, -1) for category in categories]
output = 'Percentage spent by Category\n'
percent = 100
while percent >= 0:
cat_spaces = ' '
for spending in percentage_spending:
if spending >= percent:
cat_spaces += 'o '
else:
cat_spaces += ''
output += str(percent).rjust(3) + '|' + cat_spaces + ('\n')
percent -= 10
dashes = '-' + '---' * len(categories)
names = []
x_axis = ''
for category in categories:
names.append(category.name)
maximum = max(names, key=len)
for i in range(len(maximum)):
name_string = ' '
for name in names:
if i >= len(name):
name_string += ' '
else:
name_string += name[i] + ' '
name_string += '\n'
x_axis += name_string
output += dashes.rjust(len(dashes) + 4) + '\n' + x_axis
return output
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36 Edg/86.0.622.51
.
Challenge: Budget App
Link to the challenge: