Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19986 > unrolled thread

Re: iterating over list with one mising value

Started byChris Angelico <rosuav@gmail.com>
First post2012-02-08 08:37 +1100
Last post2012-02-08 08:37 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: iterating over list with one mising value Chris Angelico <rosuav@gmail.com> - 2012-02-08 08:37 +1100

#19986 — Re: iterating over list with one mising value

FromChris Angelico <rosuav@gmail.com>
Date2012-02-08 08:37 +1100
SubjectRe: iterating over list with one mising value
Message-ID<mailman.5517.1328650642.27778.python-list@python.org>
On Wed, Feb 8, 2012 at 8:25 AM, Aaron France
<a.france.mailinglists@gmail.com> 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!

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web