Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 19)
19.
In Python, what does the generator.throw() method do?
It throws an exception inside the generator
It forcibly terminates the generator
It throws an exception outside the generator
It initializes the generator
Answer: Option
Explanation:
generator.throw() is used to throw an exception inside the generator. This can be useful for handling specific conditions within the generator.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.