Re: get each pair from a string.

Discussion in 'Python' started by Ian Kelly, Oct 21, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Sun, Oct 21, 2012 at 12:58 PM, Vincent Davis
    <> 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.
    Ian Kelly, Oct 21, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Emile van Sebille

    Re: get each pair from a string.

    Emile van Sebille, Oct 22, 2012, in forum: Python
    Replies:
    9
    Views:
    207
    Mark Lawrence
    Oct 24, 2012
  2. Ian Kelly

    Re: get each pair from a string.

    Ian Kelly, Oct 21, 2012, in forum: Python
    Replies:
    0
    Views:
    129
    Ian Kelly
    Oct 21, 2012
  3. Mark Lawrence

    Re: get each pair from a string.

    Mark Lawrence, Oct 21, 2012, in forum: Python
    Replies:
    0
    Views:
    151
    Mark Lawrence
    Oct 21, 2012
  4. Emile van Sebille

    Re: get each pair from a string.

    Emile van Sebille, Oct 22, 2012, in forum: Python
    Replies:
    0
    Views:
    179
    Emile van Sebille
    Oct 22, 2012
  5. Emile van Sebille

    Re: get each pair from a string.

    Emile van Sebille, Oct 22, 2012, in forum: Python
    Replies:
    0
    Views:
    163
    Emile van Sebille
    Oct 22, 2012
Loading...

Share This Page