My python solution for "count and say"


#1
def countAndSay(self, A):
    
    res = '1'
    
    for i in range(1, A):
        
        new_str, cnt, pr = '', 0, res[0]
        
        for l in res:
            if l == pr:
                cnt += 1
            else:
                new_str += str(cnt) + pr
                pr, cnt = l, 1
                
        new_str += str(cnt) + l
        res = new_str
        
    return res