X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63 Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!news.muarf.org!news.roellig-ltd.de!open-news-network.org!cyclone01.ams2.highwinds-media.com!news.highwinds-media.com!voer-me.highwinds-media.com!lightspeed.eweka.nl!lightspeed.eweka.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.035 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'subject:How': 0.09; 'len(x)': 0.09; 'index': 0.13; 'less,': 0.16; 'selects': 0.16; 'sequence.': 0.16; 'subject:access': 0.16; 'wrote:': 0.16; 'am,': 0.23; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'sequence': 0.27; 'message-id:@mail.gmail.com': 0.28; 'subject:list': 0.28; 'received:google.com': 0.34; 'to:addr:python-list': 0.35; 'but': 0.36; 'subject:: ': 0.37; 'tue,': 0.38; 'to:addr:python.org': 0.39; 'sure': 0.40; 'subject:the': 0.40; 'even': 0.61; 'entire': 0.61; 'matter': 0.63; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=KVF0Yp3JADhzubDIsz2Iyj8FjJMOIeag7E7KGzopxQc=; b=OeBt8YTwI1RdnyBSpuDhXKGUeLAW/6XiebYeQuKXf3uFJSq38cmlDiOB9hQNOatVJJ R9iKvPPc24awvNKiI5+1VEztR3svw/FjQqo3VT7l7jEeNNkv3+GG29u0N3TPgL7is8xV RoT7c38xKIratxusr2UY7mmnQiCQSMr1aY63P/5zrEEP47uUL/au+9z3yPLW6LPtpXNh T9SWnpg1htAyAxV/0ChOKNu0K06YtC85pssqUm5jcWowWwYdJoWJAk8cpLKYkuy0Oz/y 4mMhOj65Lmgva0lusSnnX4BujnVQrSHKFU03dQYOIf4T0rXOzy3CTRvUOU//dsQn0Lm9 P0cw== X-Received: by 10.107.136.42 with SMTP id k42mr32121899iod.63.1433254820155; Tue, 02 Jun 2015 07:20:20 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <18a4709f-47c8-41f7-87d5-08bbb00166b6@googlegroups.com> References: <18a4709f-47c8-41f7-87d5-08bbb00166b6@googlegroups.com> From: Ian Kelly Date: Tue, 2 Jun 2015 08:19:39 -0600 Subject: Re: How to access the low digits of a list To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 10 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433254823 news.xs4all.nl 2842 [2001:888:2000:d::a6]:58979 X-Complaints-To: abuse@xs4all.nl X-Received-Body-CRC: 425347069 X-Received-Bytes: 3374 Xref: csiph.com comp.lang.python:91843 On Tue, Jun 2, 2015 at 6:35 AM, Rustom Mody wrote: > For that matter even this works > But I am not sure whats happening or that I like it > >>>> [x[-2:] for x in lines] > ['12', '42', '49', '56', '25', '36', '49', '64', '81', '00'] x[-2:] selects all items in the sequence with index i such that len(x) - 2 <= i < len(x). For a sequence of length 2 or less, that's the entire sequence.