Python lists

Alex foo at email.invalid
Fri Dec 28 18:46:45 CET 2012


Manatee wrote:

> On Friday, December 28, 2012 9:14:57 AM UTC-5, Manatee wrote:
> > I read in this:
> > 
> > ['C100, C117', 'X7R 0.033uF 10% 25V  0603', '0603-C_L, 0603-C_N',
> > '10', '2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D',
> > 'Digi-Key', '490-1521-1-ND', '']
> > 
> > 
> > 
> > Then I need to convert it to this:
> > 
> > [['C100', 'C117'], 'X7R 0.033uF 10% 25V  0603', '0603-C_L',
> > '0603-C_N', '10', '2', '', '30', '15463-333', 'MURATA',
> > 'GRM188R71E333KA01D', 'Digi-Key', '490-1521-1-ND', '']]
> > 

l = ['C100, C117', 'X7R 0.033uF 10% 25V  0603', '0603-C_L, 0603-C_N',
'10', '2', '', '30', '15463-333', 'MURATA', 'GRM188R71E333KA01D',
'Digi-Key', '490-1521-1-ND', '']

[item.split(',') if i == 0 else item for i, item in enumerate(l)]



More information about the Python-list mailing list