Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 8)
8.
What will happen if a generator function reaches the end of its execution?
It raises a StopIteration exception
It automatically restarts from the beginning
It continues to the next iteration
It raises a GeneratorExit exception
Answer: Option
Explanation:
When a generator function completes its execution or reaches a return statement, it raises a StopIteration exception to indicate the end of the iteration.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.