Answer:
#required generator function
def count_seq():
    #starting with number 2. using string instead of integers for easy manipulation
    n='2'
    #looping indefinitely
    while True:
        #yielding the integer value of current n
        yield int(n)
        #initializing an empty string
        next_value=''
        #looping until n is an empty string
        while len(n)>0:
            #extracting first digit (as char)
            first=n[0]
            #consecutive count of this digit
            count=0
            #looping as long as n is non empty and first digit of n is same as first
            while len(n)>0 and n[0]==first:
                #incrementing count
                count+=1
                #removing first digit from n
                n=n[1:]
            #now appending count and first digit to next_value
            next_value+='{}{}'.format(count,first)
        #replacing n with next_value
        n=next_value
#testing, remove if you don't need this
if __name__ == '__main__':
    #creating a generator from count_seq()
    gen=count_seq()
    #looping for 10 times, printing next value
    for i in range(10):
        print(next(gen))
Explanation: