To stop iterating over iterator following should be done:
__next__ method is called during iteration over iterator. It should raise a StopIteration to signal the end of the iteration

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Python quizzes
Sign Up Now
or Subscribe for future quizzes