# Utility of this function - Budget App Project

Hi everyone.

I don’t know if I’m ignoring the obvious, but I personally don’t understand what is this function for. It multiplies a number by 10, but just after divides the number by 10 again, returning the initial number.

``````def truncate(n):
multiplier = 10
return int(n * multiplier) / multiplier

def getTotals(categories):
total = 0
breakdown = []
for category in categories:
total += category.get_withdrawls()
breakdown.append(category.get_withdrawls())
rounded = list(map(lambda x: truncate(x/total), breakdown))
return rounded
``````

Question: What Truncate function is for?

Thank you.

No, I’m trying to understand someone else code.

Yes, of course. I’m stuck so I was looking for alternatives, but I didn’t understand this particular code, so I was curious about what It does.

If something doesn’t need elaborate setup the best way to check what it is doing is trying it yourself with few examples.

Having said that, there are better ways to do, in python, what this function is achieving. Person writing this code must have been used to different language.

1 Like