Is there a way to round a python float to x decimals? For example:
>>> x = roundfloat(66.66666666666, 4)
66.6667
>>> x = roundfloat(1.29578293, 6)
1.295783
I’ve found ways to trim/truncate them (66.666666666 –> 66.6666), but not round (66.666666666 –> 66.6667).
Use the built-in function
round():help on
round():