# Python lists

Hans Mulder hansmu at xs4all.nl
Sun Dec 30 23:19:10 CET 2012

```On 28/12/12 18:46:45, Alex wrote:
> Manatee wrote:
>
>> On Friday, December 28, 2012 9:14:57 AM UTC-5, Manatee wrote:
>>>
>>> ['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)]

If it's okay to modify the original list, you can simply do:

l[0] = split(l[0], ", ")

If modifying the original is not okay, the simple solution would
be to copy it first:

l2 = l
l2[0] = split(l2[0], ", ")

Hope this helps,

-- HansM

```