<doocs>0443.String Compression_1.py
def compress( chars: List[str]) -> int:
    i, k, n = 0, 0, len(chars)
    while i < n:
        j = i + 1
        while j < n and chars[j] == chars[i]:
            j += 1
        chars[k] = chars[i]
        k += 1
        if j - i > 1:
            cnt = str(j - i)
            for c in cnt:
                chars[k] = c
                k += 1
        i = j
    return k
def sample_funcname ( var_0 : List [ str ] ) -> int :
    var_5 , var_6 , var_8 = 0 , 0 , len ( var_0 )
    while var_5 < var_8 :
        var_10 = var_5 + 1
        while var_10 < var_8 and var_0 [ var_10 ] == var_0 [ var_5 ] :
            var_10 += 1
        var_0 [ var_6 ] = var_0 [ var_5 ]
        var_6 += 1
        if var_10 - var_5 > 1 :
            var_11 = str ( var_10 - var_5 )
            for var_12 in var_11 :
                var_0 [ var_6 ] = var_12
                var_6 += 1
        var_5 = var_10
    return var_6
