Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43674
| References | <a6562e3b-29af-4953-bc8b-49fa634d1be7@googlegroups.com> <CAPTjJmoEpVxUXFM0gX+JCb3xMP6-TpQLzJ6Ln9ryK1b=dFoK_g@mail.gmail.com> |
|---|---|
| From | Matt Jones <matt.walker.jones@gmail.com> |
| Date | 2013-04-16 10:33 -0500 |
| Subject | Re: Newbie questions on Python |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.667.1366126460.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
When slicing: l[start:end:step] In your example of "a[2::-1]" you are reversing the list by using a step of -1, then you are slicing at index 2 (third element). *Matt Jones* On Tue, Apr 16, 2013 at 10:30 AM, Chris Angelico <rosuav@gmail.com> wrote: > On Wed, Apr 17, 2013 at 1:20 AM, <idkfaidkfaidkfa@gmail.com> wrote: > > Hi all, > > i'm programming in python for the first time (usually i use C as > programming language). I don't understand these results: > > > >>>> a=[1,2,3,4,5] > >>>> a[:-1] > > [1, 2, 3, 4] > >>>> a[::-1] > > [5, 4, 3, 2, 1] > >>>> a[2::-1] > > [3, 2, 1] > > > > what does a[2::-1] means? > > That's taking a slice. This page has something to say on the subject: > > http://docs.python.org/3.3/tutorial/introduction.html > > By the way, regarding your email address: there are no cheat codes in > Python... either that, or Python *is* a cheat code. :) > > ChrisA > [[ VERY HAPPY CODING ADDED ]] > -- > http://mail.python.org/mailman/listinfo/python-list >
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Newbie questions on Python idkfaidkfaidkfa@gmail.com - 2013-04-16 08:20 -0700
Re: Newbie questions on Python Chris Angelico <rosuav@gmail.com> - 2013-04-17 01:30 +1000
Re: Newbie questions on Python Walter Hurry <walterhurry@lavabit.com> - 2013-04-16 21:40 +0000
Re: Newbie questions on Python Chris Angelico <rosuav@gmail.com> - 2013-04-17 07:53 +1000
Re: Newbie questions on Python Matt Jones <matt.walker.jones@gmail.com> - 2013-04-16 10:33 -0500
Re: Newbie questions on Python Neil Cerutti <neilc@norwich.edu> - 2013-04-16 15:41 +0000
Re: Newbie questions on Python Lele Gaifax <lele@metapensiero.it> - 2013-04-16 18:06 +0200
Re: Newbie questions on Python Neil Cerutti <neilc@norwich.edu> - 2013-04-16 17:16 +0000
csiph-web