I am trying to split a string into a list, separated by a change in character, in python. I am finding this very difficult, but am sure that I am over thinking it and missi
import itertools [''.join(value) for key, value in itertools.groupby(my_str)]
>>> import re >>> my_str = 'abgg22ffeekkkk1zzabbb' >>> [m.group() for m in re.finditer(r'(.)\1*', my_str)] ['a', 'b', 'gg', '22', 'ff', 'ee', 'kkkk', '1', 'zz', 'a', 'bbb']