Python - round up to the nearest ten

raspberrysupreme picture raspberrysupreme · Oct 19, 2014 · Viewed 105.8k times · Source

If I get the number 46 and I want to round up to the nearest ten. How do can I do this in python?

46 goes to 50.

Answer

ch3ka picture ch3ka · Oct 19, 2014

round does take negative ndigits parameter!

>>> round(46,-1)
50

may solve your case.