class Solution(object): def countAndSay(self, n): """ :type n: int :rtype: str """ s=[] for i in range(n): if i==0: s.append("1") #print 1 continue test=s[i-1] flag=0 count=0 j=0 tmp=‘‘ while j<len(test): if(test[j]==test[flag]): count+=1 j+=1 continue tmp=tmp+str(count)+test[flag] #s.append(tmp) #print tmp count=0 flag=j if count>0: s.append(tmp+str(count)+test[flag]) #print s return s[n-1]