How Do I Minus A Total From It's Next Highest Multiple Of 10

45 Views Asked by At

So I have a total, say 24, I need my code to find the nearest hightest multiple of 10. This would be 30 of course, so I need the code to calculate (30-24). If the number is 20 it would be 20 beucase it is equal to a highest muliple of 10. I then need to store the result for later use.

1

There are 1 best solutions below

3
On
>>> def nh(val):
...   return 9 - ((val + 9) % 10)
... 
>>> nh(24)
6
>>> nh(20)
0