[Tutor] Process list elements as consecutive pairs
Wayne Werner
waynejwerner at gmail.com
Fri Mar 5 19:03:26 CET 2010
On Fri, Mar 5, 2010 at 11:56 AM, RĂ¼diger Wolf <
rudiger.wolf at throughputfocus.com> wrote:
> Hi
>
> 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
>
for x in xrange(0, len(listin), 2):
print listin[x], listin[x+1]
- that's probably how I'd do it anyway.
HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100305/88b7493b/attachment-0001.html>
More information about the Tutor
mailing list