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


Groups > comp.lang.python > #19986

Re: iterating over list with one mising value

References <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com>
Date 2012-02-08 08:37 +1100
Subject Re: iterating over list with one mising value
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5517.1328650642.27778.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web