لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Lesson 23: Break And Continue Statements In Python

In Python, break and continue statements can alter the flow of a normal loop.

The Python break statement stops the loop in which the statement is placed.

A Python continue statement skips a single iteration in a loop.

Both break and continue statements can be used in a for or a while loop.

The continue statement allows you to skip part of a loop when a condition is met.

The break Statement
Example: break statement we can stop the loop even if the while condition is true.

output will be
1
2
3
4

The continue Statement
Example: Continue to the next iteration if i is 4.

output will be
1
2
3
5
6
7

Example Code: How to use break statements in Python loop?


output will be
c
o
m
m
u
n
i
c
a
end

Example Code: How to use continue statements in Python loop?


output will be
c
o
m
m
u
n
i
c
a
i
o
n
end