Scientific Computing with Python Projects - Budget App

Hey everybody,
it seems like I can’t figure out why my code fails on two tests. Even though I can’t see a difference in the terminal prints. I posted my link below. I’m also grateful for any advice how to read the comments on why it failed better. Because I feel like I should be able to figure that one out myself, but I’m a bit lost.
Thanks for any advice!

Mycode so far

boilerplate-budget-app - Replit

My browser information:

User Agent is: Chrome/110.0.0.0

Challenge: Scientific Computing with Python Projects - Budget App

Link to the challenge:

Thanks a lot. Replacing the spaces by a visible character is a great idea and helped a lot, and I found a few mistakes. I appreciate that.

Sadly, there is still an issue I can’t figure out. Like you said, the unittest says the percentages are wrong. But when I use the same setup as in the test and compare the expected string with my created string, they are exact the same (You can see it in my et.py). So I don’t know how to fix this issue. I would really appreciate a hint on how to approach this issue.

et.py:

import budget
from budget import create_spend_chart


business = budget.Category("Business")
food = budget.Category("Food")
entertainment = budget.Category("Entertainment")

# the settings from the test case from test_module.py
food.deposit(900, "deposit")
entertainment.deposit(900, "deposit")
business.deposit(900, "deposit")
food.withdraw(105.55)
entertainment.withdraw(33.40)
business.withdraw(10.99)

# string created by using my budget.py
string_from_budget_app = create_spend_chart(budget.Category.categories)


string_from_test_module = "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(string_from_budget_app, string_from_test_module)

print(string_from_test_module == string_from_test_module)

Print:

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  
 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  
True

Thanks, it works!
I really still don’t get how:

print(string_from_test_module == string_from_test_module)

could reply True while there were obviously differences.
If you have an idea about that or can give me a hint, that would be great!

Thanks for the amazing help! :slight_smile:

Above, you are comparing string_from_test_module to string_from_test_module. Those will always be equal, so this will be True.

1 Like

I can’t believe I didn’t see this. I’m so done… Thanks for your patience. I’m gonna go and find a hole to bury myself. :wink:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.