Minimum and Maximum of a list containing floating point numbers

Xavier Ho contact at xavierho.com
Tue Sep 7 02:44:21 CEST 2010


On 7 September 2010 10:37, ceycey <cuneyt.ertal at gmail.com> wrote:

> I have a list like ['1.1881', '1.1881', '1.1881', '1.1881', '1.1881',
> '1.1881', '1.1881', '1.1881', '1.1881', '1.1881', '1.7689',  '1.7689',
> '3.4225', '7.7284', '10.24', '9.0601', '9.0601', '9.0601', '9.0601',
> '9.0601'].



> How can I convert the elements
> of list to float so max function finds the correct answer.
>

 >>> input = ['3.4225', '7.7284', '10.24']
>>> [float(x) for x in input]
[3.4225, 7.7284, 10.24]

HTH,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100907/fd45ad34/attachment.html>


More information about the Python-list mailing list