Post
Python
Is there any way to limit the floats to two decimals?
I want x to round to 14.98
>>>x
14.97999999999
To do so, I have tried doing this
>>> round(x, 2)
14.97999999999
This round function did not work for me. Can anyone help me?
Posted on 18th April 2024
If you are using round(x, 2), this may give
14.97999999999
So try this
print("%.2f” % round(a, 2) this will give
14.98 as the output
STILL GOT QUERIES?