Python for else loop | Just enough Python

Опубликовано: 23 Сентябрь 2019
на канале: 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...


На этой странице сайта вы можете посмотреть видео онлайн Python for else loop | Just enough Python длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Ajay Tech 23 Сентябрь 2019, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 27 раз и оно понравилось 1 зрителям. Приятного просмотра!