Would it be possible to index through a generator function?
For example, say I have a function like this:
def foo():
x = 9
yield x
yield x+1
I understand that when calling the next()
method on the generator function foo()
, the output would be 9
and then 10
. Would it be possible to go straight to the second output; 10
? I haven't thought of how to do this, except by indexing through the generator function which I also don't know how to do.