Sometimes, we want to truncate float values with Python.
In this article, we’ll look at how to truncate float values with Python.
How to truncate float values with Python?
To truncate float values with Python, we can use the round function.
For instance, we write
n = round(1.923328437452, 3)
to call round to round 1.923328437452 to 3 decimal places.
Conclusion
To truncate float values with Python, we can use the round function.