On Jan 2, 7:57 pm, "Dave Dean" <[EMAIL PROTECTED]> wrote:
> Hi all,
>   I'm looking for a way to iterate through a list, two (or more) items at a
> time.  Basically...
>
>   myList = [1,2,3,4,5,6]
>
> I'd like to be able to pull out two items at a time...

def pair_list(list_):
    return [list_[i:i+2] for i in xrange(0, len(list_), 2)]

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to