Python break statement
The break statement terminates the loop containing it. Control of the program flows to the statement immediately after the body of the loop.
If the break statement is inside a nested loop (loop inside another loop), the break statement will terminate the innermost loop.
Syntax:
break
Example:
i = 0
while i < 5:
if i == 3:
print("Executing 'break' statement in the next statment and the flow of execution is being", end = " ")
break
print(i)
i += 1
print("shifted to here!")
output:
0
1
2
Executing 'break' statement in the next statment and the flow of execution is being shifted to here!