breaking up a list
Alex Martelli
aleaxit at yahoo.com
Tue Sep 28 11:52:16 EDT 2004
More information about the Python-list mailing list
Tue Sep 28 11:52:16 EDT 2004
- Previous message (by thread): breaking up a list
- Next message (by thread): breaking up a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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...). Alex
- Previous message (by thread): breaking up a list
- Next message (by thread): breaking up a list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list