Looking for clarifications about the Budget App Project

Hi guys :
I’ve worked on this project and everything went well till trying to work on the second part of the project which is coding the function, I need some clarifications, I saw the example given in the explanation of the output code and I saw smtg weird for me

Percentage spent by category
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     

this part 60+20+10 is 90 , but from what I know the sum has to be 100 why 90?
AND I don’t understand this part below as well

Blockquote
The chart should show the percentage spent in each category passed in to the function. The percentage spent should be calculated only with withdrawals and not with deposits. Down the left side of the chart should be labels 0 - 100. The “bars” in the bar chart should be made out of the “o” character. The height of each bar should be rounded down to the nearest 10. The horizontal line below the bars should go two spaces past the final bar. Each category name should be written vertically below the bar. There should be a title at the top that says “Percentage spent by category”.

the percentage must be calculated only with withdrawals !!! So we have to sum the withdrawals and then calculate the percentage of every spent money based on the sum of withdrawals only! or there’s another way to do so. Please help me, I’ve been stuck there just because of the lack of understanding of the requirements

Withdrawls represent money that was spent.

The project wants you to compute the total amount of money spent and then compute the total percent that came from each category. Since everything is rounded to 10%, the total percents won’t perfectly add up.

1 Like

@JeremyLT Thank you for your response , but , from what I understood here’s what I have done : for example if we have 2 objects from the instance for example : and we calculated the percentages and we get 64 and 36 , so we round them to the nearest 10 so 64 will become 60 and 36 will becaom 40

    for nbr in list_nbr:
        p = (nbr / sum(list_nbr)) * 100
        # print(p)
        if p % 10 < 5:
            p = p - (p % 10)
        elif p % 10 > 5:
            p = p + (10 - p % 10)
        else:
            p = p
        list_percentage.append(int(p))

This is how I proceed , I’m sorry but how should I round the percentages and having their sum 90 ?
Thanks again for ur time

You need to round down