Page 91 - Digicode_AI_class_8
P. 91
The break Statement
The break is a keyword in Python which is used for bringing the program control out of the loop. The
break statement halts the execution of a loop and program flow switches to the statement after the
loop. A single break statement will break out of only one loop.
Syntax:
#loop statement
break
Program: To demonstrate the use of the break statement in a loop.
On running the above program, you will get the following output:
The continue Statement
The continue statement is used inside loops. When a continue statement is encountered inside
a loop, control of the program jumps to the beginning of the loop for next iteration, skipping the
execution of rest of the statements of the loop for the current iteration.
Syntax:
#loop statements
continue
#the code to be skipped
Program: To demonstrate the use of the continue statement in a loop.
Looping Statements in Python 89

