How to group sentences of identical characters in python ( 'aabcdd' -> ['aa', 'b', 'c', 'dd'] )?
<p>I have a string <code>'aabbababacccssdd'</code> from which I want to generate <code>['aa', 'bb', 'a', 'b', 'a', 'b', 'a', 'ccc', 'ss', 'dd']</code></p>

<p>Here's my present solution:</p>

<pre><code>def get_pats(n):
    n = str(n) # to support integers
    a = len(n)
    p = []
    pat_start = 0
    prev = 0
    for b in range(0, a):
        if n[b] != n[prev]:
            p.append(n[pat_start:b])
            prev = b
            pat_start = b
    p.append(n[pat_start:b+1])
    return p
</code></pre>

<p>The solution works good enough, but I was wondering if there is a more elegant/pythonic way to do this?</p>
