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


Groups > comp.lang.python > #62055

Re: Wrapping around a list in Python.

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <drobinow@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.033
X-Spam-Evidence '*H*': 0.95; '*S*': 0.01; '16,': 0.03; 'skip:[ 20': 0.04; 'cc:addr:python-list': 0.11; 'assume': 0.14; 'array.': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'array': 0.29; 'dec': 0.30; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; 'continues': 0.31; 'display': 0.35; 'received:google.com': 0.35; 'rather': 0.38; 'how': 0.40; 'such': 0.63; 'grab': 0.64; 'to:none': 0.92; 'hundred': 0.95; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=LL6W2xOqJkv5MKp3cEjf44Z6TUhzX7LPlpSFk6JaqDo=; b=Hxlt6aUtxzgcBhQ0gMiaKnpSjooHKHrEqDd9SPpcezDAqSoEgs99DQLWu6R8WMNHG1 zZAslA8t7E4qG8uOjbV4jXJVqaYQGxtr1LRcHwuPXLNut4Nc3hAAq234zMK1+GLzWLrD bPCNAi7RpbDp0IMG3Kd0L5RzJSQQrMUV+u06+t4TUFVnQDDMwR1TH/cfAj92DdeAjXz/ Yza5VJUxx45vHCl94COImPMZIdLPx99EmlE4JPZZtEbkNespCmbZVbcmxYPTvBLI8S/M 2AV7U9OSnukjtn/xj3+865E7EmcpXrY6N29l1d1k6zcR24Oy2O3zx1qPblmA9ayVAQRs kcLA==
MIME-Version 1.0
X-Received by 10.182.129.201 with SMTP id ny9mr11428725obb.0.1387197718027; Mon, 16 Dec 2013 04:41:58 -0800 (PST)
In-Reply-To <cf42bb27-a2c9-4a94-9c74-a6ff1253a2ee@googlegroups.com>
References <e8123076-9f52-4a72-b262-908a5dcc8a10@googlegroups.com> <mailman.4181.1387171006.18130.python-list@python.org> <cf42bb27-a2c9-4a94-9c74-a6ff1253a2ee@googlegroups.com>
Date Mon, 16 Dec 2013 07:41:57 -0500
Subject Re: Wrapping around a list in Python.
From David Robinow <drobinow@gmail.com>
Cc python-list@python.org
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4211.1387197726.18130.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387197726 news.xs4all.nl 2897 [2001:888:2000:d::a6]:54665
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62055

Show key headers only | View raw


On Mon, Dec 16, 2013 at 12:26 AM,  <shengjie.shengjie@live.com> wrote:
> The idea is to grab the last 4 elements of the array. However i have an array that contains a few hundred elements in it. And the values continues to .append over time. How would i be able to display the last 4 elements of the array under such a condition?

I assume you mean 'list' rather than 'array'.
If all you want to do is 'display' the last 4 elements:

big_list = [0,1,2,3,4,5,6,7,8,9]
last4 =  big_list[-4:]
print(last4)

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


Thread

Wrapping around a list in Python. shengjie.shengjie@live.com - 2013-12-15 20:38 -0800
  Re: Wrapping around a list in Python. Ben Finney <ben+python@benfinney.id.au> - 2013-12-16 15:59 +1100
    Re: Wrapping around a list in Python. shengjie.shengjie@live.com - 2013-12-15 21:07 -0800
      Re: Wrapping around a list in Python. shengjie.shengjie@live.com - 2013-12-15 21:10 -0800
        Re: Wrapping around a list in Python. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-16 09:33 +0000
    Re: Wrapping around a list in Python. Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-16 10:12 +0000
  Re: Wrapping around a list in Python. Gary Herron <gary.herron@islandtraining.com> - 2013-12-15 21:10 -0800
    Re: Wrapping around a list in Python. shengjie.shengjie@live.com - 2013-12-15 21:26 -0800
      Re: Wrapping around a list in Python. Peter Otten <__peter__@web.de> - 2013-12-16 10:15 +0100
      Re: Wrapping around a list in Python. David Robinow <drobinow@gmail.com> - 2013-12-16 07:41 -0500
      Re: Wrapping around a list in Python. Dave Angel <davea@davea.name> - 2013-12-16 07:51 -0500
  Re: Wrapping around a list in Python. shengjie.shengjie@live.com - 2013-12-15 21:26 -0800

csiph-web