def custom_round(x, base=0.5): return base * round(float(x)/base) # you can replace the base parameter with the nearest rounding you need