To stop iterating over iterator following should be done:
Explanation
__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
Cosmo
Sign Up Now
or Subscribe for future quizzes