Tell us what’s happening:
create_spend_chart is throwing errors, even though expected and actual are identical.
If anyone could help out that would be great.
Your code so far
def create_spend_chart(categories):
percent = 0
dashes = '-'
cate_names = list()
withdraw_sum = 0
for item in categories:
withdraw_sum += item.withdraw_item
chart = "Percentage spent by category\n"
for i in range(100, -10, -10):
chart += f"{i}".rjust(3) + '|'.ljust(2)
for cate in categories:
percent = round(((cate.withdraw_item / withdraw_sum) * 100))
if percent >= i : chart += 'o'.ljust(3)
else : chart += ' '.ljust(3)
chart += '\n'
for cate in categories:
dashes += '---'
cate_names.append(list())
for letter in cate.name:
cate_names[categories.index(cate)].append(letter)
chart += ' ' + dashes + '\n'
for line in zip_longest(*cate_names, fillvalue=' '):
if any(charac != ' ' for charac in line):
chart += ' ' + ' '.join(line) + '\n'
return chart.rstrip()
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
.
Challenge: Budget App
Link to the challenge: