Question: Trying to create Python function continuous1234 that returns a never ending generator that yields the numbers 1,2,3,4 forever. Note: Have to use something from itertools

Trying to create Python function continuous1234 that returns a never ending generator that yields the numbers 1,2,3,4 forever. Note: Have to use something from itertools which i tried below but I keep getting False on iteration? # Here is what i have so far # def continuous1234(): """Return a generator that returns the numbers 1, 2, 3, 4 continuously.""" lst = ['1', '2', '3', '4'] pool = itertools.cycle(lst) for item in pool: yield from item

# This is how it should work # from app import continuous1234

n1234 = continuous1234() iter(n1234) == n1234 True next(n1234) == 1 True next(n1234) == 2 True next(n1234) == 3 True next(n1234) == 4 True next(n1234) == 1 True next(n1234) == 2 True next(n1234) == 3 True next(n1234) == 4 True next(n1234) == 1 True next(n1234) == 2 True [...etc...]

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 Databases Questions!