iterating over list with one mising value

Chris Angelico rosuav at
Tue Feb 7 16:37:14 EST 2012

On Wed, Feb 8, 2012 at 8:25 AM, Aaron France
<a.france.mailinglists at> wrote:
> for i in range(0, len(x), 2):
>    print x[i-1], x[i]

I think you want x[i], x[i+1] here, but in any case, this is a fairly
standard non-Python way to do this sort of thing. There's a variety of
more Pythonic ways to loop, but every now and then, the old C habits
still come in handy!


More information about the Python-list mailing list