StopIteration
The example above would continue forever if you had enough next() statements, or if it was used in a for loop.
To prevent the iteration to go on forever, we can use the StopIteration statement
In the __next__() method, we can add a terminating condition to raise an error if the iteration is done a specified number of times:
Stop after 15 iterations:
Auf dieser Seite können Sie das Online-Video stopiteration python | python iterators mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Coding Study Point 16 November 2022 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 343 Mal angesehen und es wurde von like den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!