Python for else loop | Just enough Python

Publicado el: 23 septiembre 2019
en el canal de: 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...


En esta página del sitio puede ver el video en línea Python for else loop | Just enough Python de Duración hora minuto segunda en buena calidad , que subió el usuario Ajay Tech 23 septiembre 2019, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 27 veces y le gustó 1 a los espectadores. Disfruta viendo!