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
Get step-by-step solutions from verified subject matter experts
