breaking up a list
aleaxit at yahoo.com
Tue Sep 28 17:52:16 CEST 2004
Larry Bates <lbates at syscononline.com> wrote:
> > x=[1,2,3,4,5,6]
> > What's the best way of converting it into this: [[1, 2], [3, 4], [5, 6]],
> I would use:
> pairs=[[a,b] for a,b in x]
> but as you can see from other replies there are other ways.
Which is fortunate, because what you would use could never possibly work
for the value of x given by the original poster (and most other values
of x except sequences of two-items subsequences...).
More information about the Python-list