In Python, there is an else conditional statement with for/while loop unlike any other programming language, which denotes or executes when for loop is fully completed.
But else statement doesn’t execute in the case for loop terminated in between.
When for loop executes:
In the below case, for loop is executed without break in the loop so the “else” statement also gets executed.
Press enter or click to view image in full size
Scenario-1: When for loop executes
When for loop terminated in between
else statement never executes in case if there is the termination of for-loop
Press enter or click to view image in full size
Scenario-2: When for loop terminated
Conclusion- else statement is executed only when for loop does not terminate.