I want to figure out how to return generator outputs. I know that next(generator) returns the yielded output of the function, but I want to know how to return multiple yielded outputs.
For instance:
alist = [1,2,3,4,5,6]
def aiterator():
for i in alist:
yield i+1
generator = aiterator()
I know that next(generator) will return 1, but how do I return 2,3, or if I want, 2,3,4 without typing next(generator) twice or three times?
Specifically, I'm thinking of another function which will return the number of next(generator)s:
for i in aiterator():
return ?