On May 12, 3:40 pm, Dmitry Dzhus <[EMAIL PROTECTED]> 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" > map(lambda s: float(s), str.split(',')) > > Last expression returns: [53.0, 20.0, 4.0, 2.0] > -- > Happy Hacking. > > Dmitry "Sphinx" Dzhushttp://sphinx.net.ru
Nice! The following also works using split and list comprehension (as suggested in a brazilian python forum): ------------------- L = [] file = ['5,1378,1,9', '2,1,4,5'] str='' for item in file: L.append([float(n) for n in item.split(',')]) ------------------- Thank you for all suggestions! -- http://mail.python.org/mailman/listinfo/python-list