def chopup(s, t):
    """Returns grouped alignment of two strings
       in such a way that consecutive del/ins/chg operations
       are grouped to be one single operation.
       The input is two 1-to-1 aligned strings where _ = empty string.
    >>> chopup(['ka__yyab','kaxx__xy'])
    (['k', 'a', u'_', 'yy', 'ab'], ['k', 'a', 'xx', u'_', 'xy'])
    """
    def action(inchar, outchar):
        if inchar == u'_':
            return 'ins'
        elif outchar == u'_':
            return 'del'
        elif inchar != outchar:
            return 'chg'
        else:
            return 'rep'
            
    idx = 1
    s = list(s)
    t = list(t)
    while idx < len(s):
        l = action(s[idx-1], t[idx-1])
        r = action(s[idx], t[idx])
        if (l == 'rep' and r == 'rep') or (l != r):
            s.insert(idx, ' ')
            t.insert(idx, ' ')
            idx += 1
        idx += 1
    s = tuple(u'_' if u'_' in x else x for x in ''.join(s).split(' '))
    t = tuple(u'_' if u'_' in x else x for x in ''.join(t).split(' '))
    return zip(s,t)