Python Programming - Generators - Discussion

Discussion Forum : Generators - General Questions (Q.No. 24)
24.
What happens if a generator function contains a return statement with a value?
It terminates the generator with an empty result
It raises a GeneratorExit exception
It raises a StopIteration exception
It raises a RuntimeError
Answer: Option
Explanation:
If a generator function contains a return statement with a value, it will raise 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.