Welcome back to another Python video. Today we look at the difference between for vs while loops:
You use a for loop to iterate over a collection of a finite number of items.
You use a while loop when the number of loops is not known.
We show a couple of simple examples and as while loops are less common, we also dug up two more examples from our coding platform.
We also show a lesser-known construct: for...else (which also would work with a while loop).
Hope this helps distinguish between the two type of loops better.
Please comment below if you want to see videos on more beginner topics ... thanks.
En esta página del sitio puede ver el video en línea For vs while loops in Python: when to use each + practical examples de Duración hora minuto segunda en buena calidad , que subió el usuario Pybites 29 marzo 2023, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 4,285 veces y le gustó 38 a los espectadores. Disfruta viendo!