Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31857
| References | <CALyJZZURWQxgPTQcQo8kOdHkaOYbB6YE=U=vi6VrX9FoDH1gAQ@mail.gmail.com> <k61fr6$s5m$1@ger.gmane.org> <CALyJZZUui_Z_M6toRRiRmAhsGscCj_O0POw9Cb8Z8jOqW5O50g@mail.gmail.com> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2012-10-21 13:06 -0600 |
| Subject | Re: get each pair from a string. |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2599.1350846404.27098.python-list@python.org> (permalink) |
On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis <vincent@vincentdavis.net> wrote: > x = 'apple' > for f in range(len(x)-1): > print(x[f:f+2]) > > @Ian, > Thanks for that I was just looking in to that. I wonder which is faster I > have a large set of strings to process. I'll try some timings if I get a > chance later today. The solution you came up with is probably faster, but less general -- it will only work on sliceable sequences like strings, not arbitrary iterables.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: get each pair from a string. Ian Kelly <ian.g.kelly@gmail.com> - 2012-10-21 13:06 -0600
csiph-web