0

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 Answers1

1
>>> def nh(val):
...   return 9 - ((val + 9) % 10)
... 
>>> nh(24)
6
>>> nh(20)
0
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358