Rüdiger Wolf wrote:

> I am trying to Process list elements as consecutive pairs  into
> consecutive pairs.
> Any pythonic suggestions?
> 
> listin = [1,2,3,4,5,6,7,8,9,10]
> I want to process as consecutive pairs
> 1,2
> 3,4
> 5,6
> 7,8
> 9,10

>>> listin = [1,2,3,4,5,6,7,8,9,10]
>>> it = iter(listin)
>>> zip(it, it)
[(1, 2), (3, 4), (5, 6), (7, 8), (9, 10)]

If listin as an odd length the last item will be lost.

Peter

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to