Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75202
| From | Akira Li <4kir4.1i@gmail.com> |
|---|---|
| Subject | Re: How to index an array with even steps? |
| Date | 2014-07-25 16:02 +0400 |
| References | <9160a3c5-ff5f-4fb2-a125-4a1be28438b9@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12314.1406289784.18130.python-list@python.org> (permalink) |
fl <rxjwg98@gmail.com> writes: > In Python, ':' is used to indicate range (while in Matlab I know it can be used > to control steps). How to index an array with 0, 5, 10, 15...995? Just use slicing: >>> L = range(1000) # your array goes here >>> L[::5] [0, 5, 10, 15, ..., 995] # Python 2 range(0, 1000, 5) # Python 3 -- Akira
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to index an array with even steps? fl <rxjwg98@gmail.com> - 2014-07-25 04:45 -0700 Re: How to index an array with even steps? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-25 11:55 +0000 Re: How to index an array with even steps? fl <rxjwg98@gmail.com> - 2014-07-25 04:56 -0700 Re: How to index an array with even steps? Akira Li <4kir4.1i@gmail.com> - 2014-07-25 16:02 +0400
csiph-web