get each pair from a string.

Vincent Davis vincent at vincentdavis.net
Sun Oct 21 14:33:00 EDT 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121021/17e82cc9/attachment.html>


More information about the Python-list mailing list