How can I write a recursion for this function?

Solution for How can I write a recursion for this function?
is Given Below:

How can I write a recursion for this function?

def randomWord(args):
    yield random.choice(args)

list = ['book', 'apple', 'word']
books = randomWord(list)
print(next(books))
print(next(books))
print(next(books))
print(next(books))
print(next(books))

After each print(next(books)) I need to get a random word from list

Since Python 3.3 you can just use the yield from keyword.

def randomWord(args):
    yield random.choice(args)
    yield from randomWord(args)

list = ['book', 'apple', 'word']
books = randomWord(list)
print(next(books))
print(next(books))
print(next(books))
print(next(books))
print(next(books))

def randomWord(args):
    yield random.choice(args)

list = ['book', 'apple', 'word']
books = randomWord(list)

def recurse(n):
    if n == 0: return # base case

    print(next(books))
    recurse(n-1)

recurse(99) # the recurse function will call itself 99 times (for a total of 100 calls)

Not sure why you would want this as opposed to a loop…