I think this is telling me I am down to my last character/error but I can’t seem to get it right. any ideas?
Thanks in advance,
Tony
python main.py
973.96
*************Food*************
initial deposit 1000.00
groceries -10.15
restaurant and more foo -15.89
Transfer to Clothing -50.00
Total: 923.96
***********Clothing***********
Transfer from Food 50.00
-25.55
Total: 24.45
100|
90|
80|
70|
60| o
50| o
40| o
30| o
20| o o
10| o o o
0| o o o
----------
F C A
o l u
o o t
d t o
h
i
n
g
.F.........
======================================================================
FAIL: test_create_spend_chart (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/boilerplate-budget-app-8/test_module.py", line 94, in test_create_spend_chart
self.assertEqual(actual, expected, 'Expected different chart representation. Check that all spacing is exact.')
AssertionError: '100| \n 90| \n 80| [355 chars] \n' != 'Percentage spent by category\n100| [383 chars] t '
+ Percentage spent by category
100|
90|
80|
70| o
60| o
50| o
40| o
30| o
20| o o
10| o o
0| o o o
----------
B F E
u o n
s o t
i d e
n r
e t
s a
s i
n
m
e
n
- t
? -
+ t : Expected different chart representation. Check that all spacing is exact.
----------------------------------------------------------------------
Ran 11 tests in 0.055s
FAILED (failures=1)
Here is the code:
def create_spend_chart(categories):
total = 0
subtotal = 0
percent = dict()
names = []
for categ in categories:
subtotal = categ.get_withdrawls()
total = total + subtotal
for categ in categories:
subtotal = categ.get_withdrawls()
percent[categ] = int(((subtotal / total) * 100)-10)
rows = 10
outp = ""
while rows >= 0:
x = str(rows * 10) + "|"
outp = outp + f"{x:>4}"
rows -= 1
for category in categories:
if percent[category] >= rows * 10:
outp = outp + " o "
else:
outp = outp + " "
outp = outp + " \n"
a = ""
x = 0
for category in categories:
names.append(category.name)
x += 1
res = max(len(ele) for ele in names)
outp += ' -' + '---'*x + '\n'
for x in range(res):
outp = outp + " "
for name in names:
try:
outp = outp + (name[x])+" "
except:
outp = outp + " "
outp = outp + "\n"
#outp = outp.rstrip()
#outp = outp + " "
return (outp)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36
.
Challenge: Budget App
Link to the challenge: