Hi there,
I have completed all the tests in the budget app except for the create spend chart test and I know why it is failing as the bars are automatically being sorted from highest to lowest. Could someone help me find a way around this?
Here is my code:
https://replit.com/@SPARKSCoder/boilerplate-budget-app#budget.py
Thanks
It’s not even running the tests right now in this repl. It fails with
Ran 0 tests in 0.000s
OK
973.96
Traceback (most recent call last):
File "main.py", line 19, in <module>
print(food)
File "/home/runner/boilerplate-budget-app-5/budget.py", line 38, in __str__
string = f"{star*star_len.__ceil__()}{self.category}{star*star_len.__floor__()}\n"
AttributeError: 'float' object has no attribute '__ceil__'
as you are calling floor()
and ceil()
on an occasionally odd integer divided by two (so not an integer…)
Also, you typically shouldn’t call the double-underscore (dunder) methods directly as floor(obj)
will call the __floor__()
method defined on obj
’s class (if it’s defined).
Sorry… I copy and paste all my code from VS Code and I add the tests at the bottom to see how many tests I have passed. I have fixed the code and the bars are right but it still marks the code wrong. Could you please help me?
Your white space is incorrect:
- n
? -
+ n
- t
? --
+ t : Expected different chart representation. Check that all spacing is exact.
The -
lines are your output and the +
lines are expected output and the ?
lines are indicating the problems.
Thank you so much for taking the time