Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 23)
23.
What is the purpose of the generator.__next__() method?
It returns the next value from the generator
It initializes the generator
It raises a StopIteration exception
It is not a valid method for generators
Answer: Option
Explanation:
generator.__next__() is used to manually retrieve the next value from a generator. It is equivalent to calling next(generator).
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.