My only problem lies in the create_spend_chard method or rather it representation. The test states that my output and the correct output are not the same. However, diff viewers does not see a difference:
What to do?
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Challenge Information:
Build a Budget App Project - Build a Budget App Project
Ran 1 test in 0.000s
======================================================================
2
FAIL: test_create_spend_chart (test_module.UnitTests.test_create_spend_chart)
2
Traceback (most recent call last):
2
File "/home/pyodide/test_module.py", line 23, in test_create_spend_chart
2
self.assertEqual(actual, expected, 'Expected different chart representation. Check that all spacing is exact.')
2
AssertionError: 'Perc[34 chars] \n 90| \n 80| \n 70| o[329 chars] t ' != 'Perc[34 chars] \n 90| \n 80| \n 70| [340 chars] t '
2
Percentage spent by category
- 100|
+ 100|
? +
- 90|
+ 90|
- 80|
+ 80|
- 70| o
+ 70| o
- 60| o
+ 60| o
- 50| o
+ 50| o
- 40| o
+ 40| o
- 30| o
+ 30| o
- 20| o o
+ 20| o o
- 10| o o
+ 10| o o
- 0| o 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
t : Expected different chart representation. Check that all spacing is exact.
Ran 1 test in 0.005s
FAILED (failures=1)
Ran 1 test in 0.001s
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
I checked with the code I posted and for me the category class works without problems. The only thing I’m wondering about is why it doesn’t accept the create_spend_chart method.
you have an issue with spaces, add this and see, the spaces in the output are replaced with dots. There is both your code and the expected one being printed.
food = Category("Food")
entertainment = Category("Entertainment")
business = Category("Business")
food.deposit(900, "deposit")
entertainment.deposit(900, "deposit")
business.deposit(900, "deposit")
food.withdraw(105.55)
entertainment.withdraw(33.40)
business.withdraw(10.99)
actual = create_spend_chart([business, food, entertainment])
expected = "Percentage spent by category\n100| \n 90| \n 80| \n 70| o \n 60| o \n 50| o \n 40| o \n 30| o \n 20| o o \n 10| o o \n 0| o o o \n ----------\n B F E \n u o n \n s o t \n i d e \n n r \n e t \n s a \n s i \n n \n m \n e \n n \n t "
print("actual" + "\n\n" + actual.replace(' ', '.') + '\n\n')
print("expected" + "\n\n" + expected.replace(' ', '.'))