Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 36)
36.
How does the generator.throw(StopIteration) method affect a running generator?
It raises a StopIteration exception inside the generator
It forcibly terminates the generator
It has no effect on the running generator
It restarts the generator from the beginning
Answer: Option
Explanation:
generator.throw(StopIteration) forcibly terminates the running generator by raising a StopIteration exception.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.