round numbers in an array without importing Numeric or Math?
Lance Hoffmeyer
lance at augustmail.com
Tue May 16 14:41:37 EDT 2006
May have a complicating issue with the array? Have
the numbers have been interpreted as strings? I have
been pulling them from a Word doc using regex's
print Test
[u'9.0', u'58.6', u'97.8', u'10.0', u'9.6', u'28.1']
Lance
Alexander Schmolck wrote:
> Lance Hoffmeyer <lance at augustmail.com> writes:
>
>> Is there an easy way to round numbers in an array?
>>
>> I have
>> Test = [1.1,2.2,3.7]
>>
>> and want to round so the values are
>>
>> print Test [1,2,4]
>
> [int(x+0.5) for x in Test]
>
> 'as
More information about the Python-list
mailing list