Budget App Python - Rounding Problem

Hey Everyone !
I have a problem in my rounding . Can anyone help me?
replit : repl.it
I Know I have still didn’t complete the chart but I need to fix this first.

What’s the problem with your rounding?

It does not round to the highest ten as I do not want nearest.
Like using this code :

food = budget.Category(“Food”)
food.deposit(1000, “initial deposit”)
food.withdraw(10.15, “groceries”)
food.withdraw(15.89, “restaurant and more food for dessert”)
print(food.get_balance())
clothing = budget.Category(“Clothing”)
food.transfer(50, clothing)
clothing.withdraw(25.55)
clothing.withdraw(100)
auto = budget.Category(“Auto”)
auto.deposit(1000, “initial deposit”)
auto.withdraw(15)
print(create_spend_chart([food, clothing, auto]))
It does not output like this in the challenge page :

100|          
 90|          
 80|          
 70|          
 60| o        
 50| o        
 40| o        
 30| o        
 20| o  o     
 10| o  o  o  
  0| o  o  o  
    ----------

“The height of each bar should be rounded down to the nearest 10.”

So you want to take a float (50.45) and cast it to an int (50) ?

that is what makes sense but if you see challenge’s page output it is not like this like it wants to cast it to int(60)

Are you sure the problem is with your rounding? How do you know?

Here’s an example of your percentages printed:
10.0
50.0
0.0

They need to add up to 100.

The percentage spent should be calculated only with withdrawals and not with deposits.

It’s poorly written, but they mean you take the total $ spent, and say what percent was spent on each catagory. It needs to add close to 100% (keeping in mind they are round down to the nearest 10)

Thanks . I 'll rewrite my code again :heart:

1 Like

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