On 10/21/2012 11:33 AM, 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'

Maybe zip before izip for a noob?

>>> s="apple"
>>> [a+b for a,b in zip(s, s[1:])]
['ap', 'pp', 'pl', 'le']
>>>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to