Python Forum

Full Version: Rounding to the nearest eight
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Basically, I just need to round a number to the nearest eight and by my research the
round()
function cannot do that.
Divide by 8, round(), multiply by 8.

>>> round(3.9 / 8) * 8
0
>>> round(4.1 / 8) * 8
8
Thanks! That worked.