round not rounding to 0 places

Cameron Laird claird at lairds.us
Wed Aug 16 09:21:15 EDT 2006


In article <mailman.9407.1155714428.27775.python-list at python.org>,
Tim Leslie <tim.leslie at gmail.com> wrote:
>On 16 Aug 2006 00:19:24 -0700, Fuzzydave <Fuzzygoth at gmail.com> wrote:
>> I have been using a round command in a few places to round
>> a value to zero decimal places using the following format,
>>
>> round('+value+', 0)
>>
>> but this consistantly returns the rounded result of the value
>> to one decimal place with a zero
>>
>> EG:
>>
>> 4.97 is returned as 5.0 when i want it returned as 5, does
>> anyone know why this is and if i can get the round to make
>> the value 5?
>
>round returns a float. You probably want to convert it to an int.
>
>>>> int(round(4.97))
>5
			.
			.
			.
I'm surprised no one has recommended

    "%.0f" % 4.97



More information about the Python-list mailing list