how to split a string (or sequence) into pairs of characters?

Andrew Koenig ark at
Thu Aug 15 23:04:19 CEST 2002

Berthold> Andrew Koenig <ark at> writes:
Jason> Can anyone come up with a better way of performing these
Jason> operations? Extra kudos if it easily extends to any sublength
Jason> and not just pairs.
>> >>> import re
>> >>> re.findall('..', 'aabbccddee')
>> ['ab', 'cd', 'ef']

Berthold> Aehm,

>>>> re.findall('..', 'aabbccddee')
Berthold> ['aa', 'bb', 'cc', 'dd', 'ee']

Oops -- I cut and pasted from the wrong window.

Andrew Koenig, ark at,

More information about the Python-list mailing list