Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!multikabel.net!newsfeed20.multikabel.net!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.044 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'am,': 0.12; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'non- python': 0.16; 'pythonic': 0.16; 'x[i]': 0.16; '\xa0print': 0.16; 'wed,': 0.17; 'wrote:': 0.18; 'subject:list': 0.21; 'header:In- Reply-To:1': 0.22; 'feb': 0.22; 'loop,': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'message-id:@mail.gmail.com': 0.29; 'fairly': 0.30; 'habits': 0.30; 'sort': 0.33; 'here,': 0.35; 'to:addr:python-list': 0.35; 'but': 0.37; 'received:google.com': 0.37; 'subject:with': 0.37; 'received:209.85': 0.38; 'think': 0.38; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'more': 0.61; 'aaron': 0.67; 'subject:one': 0.77; 'subject:over': 0.84; 'subject:value': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=hQcAV5O/6NL0VqtQrm1AJ3lSfvN3qbQgpZV9nepvSJA=; b=jPExnIq2hpkOELCpcjxy65DlakeLjBg6JY9u8NNOSZ5VlalU8M8IVLJWfkD6B+O22c Wp5uM5OqN+tUetI3EiWX8fYpyHyBJjeqocO5UysWFbkaPCzeHEGmHFtzFE4+PfZLu1Rl 9DsnKjYWo2yKel7V98glVBfsrWPcNb+cMPUS8= MIME-Version: 1.0 In-Reply-To: <4F3196B9.8080109@gmail.com> References: <1328646189.84221.YahooMailClassic@web161206.mail.bf1.yahoo.com> <4F319406.8060206@mrabarnett.plus.com> <4F3196B9.8080109@gmail.com> Date: Wed, 8 Feb 2012 08:37:14 +1100 Subject: Re: iterating over list with one mising value From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 11 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328650642 news.xs4all.nl 6865 [2001:888:2000:d::a6]:32828 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19986 On Wed, Feb 8, 2012 at 8:25 AM, Aaron France wrote: > for i in range(0, len(x), 2): > =A0 =A0print 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