State True or False:
“In a Python program, if a break statement is given in a nested loop, it terminates the execution of all loops in one go.”
Answer
Answer by student:
False
Detailed answer by teachoo:
A break statement in a nested loop only terminates the execution of the innermost loop that contains it. The outer loops continue to execute normally.
For example, consider the following Python program:
As we can see, the break statement only terminates the inner loop when i == j, but the outer loop continues to iterate until i reaches 4.
Therefore, the statement is false .