get each pair from a string.

Mark Lawrence breamoreboy at yahoo.co.uk
Sun Oct 21 15:05:59 EDT 2012


On 21/10/2012 19:33, Vincent Davis wrote:
> I am looking for a good way to get every pair from a string. For example,
> input:
> x = 'apple'
> output
> 'ap'
> 'pp'
> 'pl'
> 'le'
>
> I am not seeing a obvious way to do this without multiple for loops, but
> maybe there is not :-)
> In the end I am going to what to get triples, quads....... also.
>
> Thanks
> Vincent
>

I suggest that you try taking slices out of your apple :)  Start here 
http://docs.python.org/tutorial/introduction.html

-- 
Cheers.

Mark Lawrence.




More information about the Python-list mailing list