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

Andrew Koenig ark at research.att.com
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 research.att.com, http://www.research.att.com/info/ark



More information about the Python-list mailing list