Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 27)
27.
What does the generator.throw(ExceptionType, value) method do?
It raises a custom exception inside the generator
It raises a StopIteration exception
It initializes the generator with the provided value
It has no effect on the generator
Answer: Option
Explanation:
generator.throw(ExceptionType, value) raises a custom exception of type ExceptionType with the specified value inside the generator.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.