Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 6)
6.
What is the purpose of the next() function when working with generators?
It generates the next random number
It retrieves the next element from the generator
It initializes the generator function
It terminates the generator
Answer: Option
Explanation:
The next() function is used to retrieve the next element produced by a generator. It advances the generator's state and returns the value generated by the yield statement.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.