Is there any way to convert a floating point number in Python to an integer except math.floor()?
I have already tried math.floor(), but I am getting an error says:
Cannot import math
Any other way?
Is there any way to convert a floating point number in Python to an integer except math.floor()?
I have already tried math.floor(), but I am getting an error says:
Cannot import math
Any other way?
You can:
int(3.14)import math then math.floor(3.14) or math.ceil(3.14) (depending on which way you want to round) (you said this doesn't work but I'll leave it for reference)x = x - x % 1 or x -= x % 1