Packing list elements into tuples

Nickolay Kolev nmkolev at uni-bonn.de
Tue Nov 9 16:59:16 EST 2004


Nickolay Kolev wrote:

> Hi all,
> 
> I have a list whose length is a multiple of 3. I want to get a list  of 
> tuples each of which has 3 consecutive elements from the original list, 
> thus packing the list into smaller packets. Like this:

I found it in the cookbook: 
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/303060

It looks quite cryptic, could anyone give me some pointers at what 
exactly is going on in the function?

Cheers,
   -- Nickolay



More information about the Python-list mailing list