```
class Solution(object):
def countAndSay(self, n):
"""
:type n: int
:rtype: str
"""
result = "1"
for i in range(n - 1):
result = self.generate(result)
return "".join(result)
def generate(self, seed):
current = None
count = 0
for i in seed:
if current != i:
if current is not None:
yield str(count)
yield current
current = i
count = 1
else:
count += 1
yield str(count)
yield current
```