Basic question

Grant Edwards grante at visi.com
Sat May 12 14:45:50 EDT 2007


On 2007-05-12, Cesar G. Miguel <cesar.gomes at gmail.com> wrote:

> Actually I'm trying to convert a string to a list of float numbers:
> str = '53,20,4,2' to L = [53.0, 20.0, 4.0, 2.0]

>>> str = '53,20,4,2'

>>> [float(w) for w in str.split(',')]

[53.0, 20.0, 4.0, 2.0]

>>> map(float,str.split(','))

[53.0, 20.0, 4.0, 2.0]

-- 
Grant Edwards                   grante             Yow!  I want you to
                                  at               MEMORIZE the collected
                               visi.com            poems of EDNA ST VINCENT
                                                   MILLAY... BACKWARDS!!



More information about the Python-list mailing list