Truncate all numbers after decimal

How do you truncate all numbers after a decimal number in Python 3?

For example, we trim 3.444 equal to 3.

+5
source share
2 answers

Converting it to int:

>>> num = 3.444
>>> int(num)
3
+12
source
>>> import math
>>> num = 3.4444
>>> math.trunc(num)
3
+5
source

All Articles