Python Programming - Generators - Discussion
Discussion Forum : Generators - General Questions (Q.No. 68)
68.
How does the
generator.throw(StopIteration)
method differ from raise StopIteration
when used with a generator?
Answer: Option
Explanation:
generator.throw(StopIteration)
is used to stop the generator and raise a StopIteration
exception inside the generator. raise StopIteration
is used outside the generator to signal the end of the iteration.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers