What does the 'else' statement in a loop signify in Python?
Correct answer
C. It is executed if the loop completes without encountering a 'break' statement
17 views
C. It is executed if the loop completes without encountering a 'break' statement
17 views
In Python loops, the 'else' statement is executed if the loop completes all iterations without encountering a 'break' statement. It is useful for executing code after the loop has completed successfully.
Not sure why the answer is C? Ask here and get an explanation.