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

Andrew Koenig ark at
Thu Aug 15 21:55:09 CEST 2002

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']

Andrew Koenig, ark at,

More information about the Python-list mailing list