class Solution(object):
def countAndSay(self, n):
"""
:type n: int
:rtype: str
"""
res =[[]for_in range(0, n)]
res[0].append('1')for i, j in enumerate(res):
if i == len(res)-1:
break
else:
length = len(j)if length ==1:
res[i+1].append('1')
res[i+1].append('1')
else:
left =0
right =0while right < length-1:
if j[right+1]== j[left]:
right +=1
else:
res[i+1].append(str(right-left +1))
res[i+1].append(res[i][left])
right +=1
left = right
if right >= length-1:
res[i + 1].append(str(right - left + 1))
res[i + 1].append(res[i][left])
right +=1
left = right
return"".join(res[-1])