Packing list elements into tuples

Nickolay Kolev nmkolev at
Tue Nov 9 22:59:16 CET 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:

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

   -- Nickolay

More information about the Python-list mailing list