stopiteration python | python iterators

Publié le: 16 novembre 2022
sur la chaîne: Coding Study Point
343
like

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:


Sur cette page du site, vous pouvez voir la vidéo en ligne stopiteration python | python iterators durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Coding Study Point 16 novembre 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 343 fois et il a aimé like téléspectateurs. Bon visionnage!