Question: Write the generator function genInf(aList) that takes in a Python list and returns a generator which yields all the items in the provided list one

Write the generator function genInf(aList) that takes in a Python list and returns a generator which yields all the items in the provided list one by one in an infinite loop. Do not use the Tab key to denote indentation, instead, use the space bar

def genInf(aList):

'''

>>> g = genInf([5,'a',2])

>>> next(g)

5

>>> next(g)

'a'

>>> next(g)

2

>>> next(g)

5

>>> next(g)

'a'

>>> next(g)

2

'''

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!