Python lists
Joel Goldstick
joel.goldstick at gmail.com
Fri Dec 28 09:37:36 EST 2012
On Fri, Dec 28, 2012 at 9:19 AM, Roy Smith <roy at panix.com> wrote:
> In article <8f5cfb99-d1d7-42d7-858a-89dd23cd532f at googlegroups.com>,
> Manatee <markrivet at gsoftcon.com> 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', '']]
>
> You want to convert it into a syntax error???
>
> You've got an extra ']' in there somewhere. I'm guessing it's the one
> at the end, but that's just a guess. Could you clarify what you meant?
>
If Roy was right, and that last ] is a type then I would do this:
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', '']
new_l = L[1:] # this removes the 'C100,C117' item from the original list
first_item = L[:1] # this is 'C100, C117'
>From here you can split first_item into two strings, and create your final
list with the pieces
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121228/4c2b13c7/attachment.html>
More information about the Python-list
mailing list