Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91996
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-06-03 14:08 -0700 |
| References | <efe9d48e-9aaf-4e68-aa26-c83da32e80f5@googlegroups.com> <18a4709f-47c8-41f7-87d5-08bbb00166b6@googlegroups.com> <mailman.63.1433254823.13271.python-list@python.org> |
| Message-ID | <11005554-e89f-407c-8720-fae1bb3fced8@googlegroups.com> (permalink) |
| Subject | Re: How to access the low digits of a list |
| From | Rustom Mody <rustompmody@gmail.com> |
On Tuesday, June 2, 2015 at 7:50:58 PM UTC+5:30, Ian wrote: > 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. Thanks -- learn something So it means that indices can give indexerror; slices cannot? Seems fair enough put that way, but is visually counterintuitive
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to access the low digits of a list fl <rxjwg98@gmail.com> - 2015-06-02 05:23 -0700
Re: How to access the low digits of a list Joel Goldstick <joel.goldstick@gmail.com> - 2015-06-02 08:32 -0400
Re: How to access the low digits of a list Frank Stutzman <stutzman@cat2.kjsl.com> - 2015-06-02 12:34 +0000
Re: How to access the low digits of a list Rustom Mody <rustompmody@gmail.com> - 2015-06-02 05:35 -0700
Re: How to access the low digits of a list Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-02 08:19 -0600
Re: How to access the low digits of a list Rustom Mody <rustompmody@gmail.com> - 2015-06-03 14:08 -0700
Re: How to access the low digits of a list Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-06-03 22:41 +0100
Re: How to access the low digits of a list Ian Kelly <ian.g.kelly@gmail.com> - 2015-06-03 16:36 -0600
Re: How to access the low digits of a list Steven D'Aprano <steve@pearwood.info> - 2015-06-04 23:27 +1000
Re: How to access the low digits of a list Steven D'Aprano <steve@pearwood.info> - 2015-06-03 01:11 +1000
csiph-web