tags:

views:

221

answers:

4

round(123,-2) 100.0

How to round it to 100 instead of 100.0?

+11  A: 
int(round(123,-2))

The int function can be used to convert a string or number to a plain integer.

codaddict
+2  A: 

you can just throw it in int:

In [1]: int(round(123, -2))
Out[1]: 100
Autoplectic
+1  A: 

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
>>>
S.Mark
A: 

You can use regular expression : (\d+)\..* to match the entire thing and extract only the integer part.

Joseph