On May 12, 3:09 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > Cesar G. Miguel wrote: > > ------------------------------------- > > L = [] > > file = ['5,1378,1,9', '2,1,4,5'] > > str='' > > for item in file: > > j=0 > > while(j<len(item)): > > while(item[j] != ','): > > str+=item[j] > > j=j+1 > > if(j>= len(item)): break > > > if(str != ''): > > L.append(float(str)) > > str = '' > > > j=j+1 > > > print L > > But I'm not sure this is an elegant pythonic way of coding :-) > > Example: > > In [21]: '5,1378,1,9'.split(',') > Out[21]: ['5', '1378', '1', '9'] > > So, instead of doing that while-based traversal and parsing of `item`, > just split it like above, and use a for loop on it. It's much more > elegant and pythonic. > > HTH, > Karlo.
Great! Now it looks better :-) -- http://mail.python.org/mailman/listinfo/python-list