Python for else loop | Just enough Python

Publié le: 23 septembre 2019
sur la chaîne: Ajay Tech
27
1

This is a syntax that is kind of unique to Python. The syntax applies equally well with while statement as well. It is more of a convenience function, but newbies get confused with this syntax some times. It basically means that if nothing is found in the loop, do something in the else part. Typically, when searching for something in a loop, we want to do something when nothing has been found – How would we know if the loop ended because of a break statement or if the loop has completed all of its iterations ?

The else in for else is used to indicate a situation where the loop has been exhausted, not broken.

https://ajaytech.co/python-loops/#for...


Sur cette page du site, vous pouvez voir la vidéo en ligne Python for else loop | Just enough Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Ajay Tech 23 septembre 2019, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 27 fois et il a aimé 1 téléspectateurs. Bon visionnage!