round floats in blender

i’m making a script for generating objects with random height, width and length, but with the random module i’m getting far too much decimals, and the round module doesn’t work
(tried round and Round). any ideas?


a=23.456567
print(round(a,1))

work

:confused:?


>>> a=1.213542543543574533574254357354
>>> round(a)
1

>>> a=1.213542543543574533574254357354
>>> round(a,6)
1.213543

that doen’t work in blender…

valter’s solution does work in blender, thanks

???
oh ok.
the (working, of course) code I pasted was typed in the blender console, not in a text block. in the console you don’t need to use print to display the result of the round() function.
… and >>> is the console prompt, don’t type it :wink:

well in my script it gave an error, strange