Consecutive Character Sequences

Aries Sun sun.aries at gmail.com
Thu Jul 14 18:15:49 CEST 2005


Hi George,

Here's the result:
>>> [list(group) for _,group in it.groupby("taaypiqee88adbbba")]
[['t'], ['a', 'a'], ['y'], ['p'], ['i'], ['q'], ['e', 'e'], ['8', '8'],
['a'], ['d'], ['b', 'b', 'b'], ['a']]
>>> [len(list(group)) for _,group in it.groupby("taaypiqee88adbbba")]
[1, 2, 1, 1, 1, 1, 2, 2, 1, 1, 3, 1]
>>>

According to the above output, your solution is correct.

Regards,
Aries




More information about the Python-list mailing list