round(123,-2) 100.0
How to round it to 100 instead of 100.0?
round(123,-2) 100.0
How to round it to 100 instead of 100.0?
int(round(123,-2))
The int function can be used to convert a string or number to a plain integer.
you can just throw it in int
:
In [1]: int(round(123, -2))
Out[1]: 100
You could use int(100.0)
to convert to 100
in python 2.x and in python3.x, its just works
Python 3.1.2 (r312:79149, ...
>>>
>>> round(123,-2)
100
>>>
You can use regular expression : (\d+)\..* to match the entire thing and extract only the integer part.