For/Else Loop

For/Else Loop


Today I encounter python snippet code and something take my attention. And the concept is similar to below code.

And I recognize else statement is not given an error. After some research, I found the miracle, for/else loop. The concept of this loop is when for is finished without break else statement run if break else statement is passed. Bellow code is an example of usage.

This tip is can be helpful you can check for loops in for loops it can be more efficient in some cases

Leave a Reply

Your email address will not be published. Required fields are marked *