Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 52)
52.
How does the generator.__next__() method differ from next(generator) when used with a generator?
They are equivalent in functionality
generator.__next__() is not a valid method for generators
generator.__next__() is used to get the next value, while next(generator) is used to restart the generator
next(generator) is used to get the next value, while generator.__next__() is used to restart the generator
Answer: Option
Explanation:
generator.__next__() and next(generator) are equivalent methods for getting the next value from a generator.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.