Is there a simple way to round in python to the nearest X value? For example, to round to the nearest tens I can do:
>>> round(1845,-1)
1840
What about if I wanted to round to the nearest...?
# round down when there's ambiguity
number = 1845
round(10, 1845) ==> 1840
round(5, 1845) ==> 1845
round(2, 1845) ==> 1844
round(50, 1845) ==> 1850
etc.
>>> round = lambda multiple, number: (number // multiple) * multiple
>>> round(1855, 10)
1850
Should work (partially -- always rounds down, see comment below), but wondering any other solutions (just for fun) ?