http://www.perlmonks.org?node_id=638457


in reply to Yet Another Rosetta Code Problem (Perl, Ruby, Python, Haskell, ...)

That would be:
#!/usr/bin/env python str = "ABBBCCDDZ" parts = [] for i in range(len(str)): if len(parts)>0: if parts[len(parts)-1][len(parts[len(parts)-1])-1]==str[i]: parts[len(parts)-1] += str[i] else: parts.append(str[i]) else: parts.append(str[i]) print parts
- Antonio Ognio, Lima-Peru