Jump statements are used to control the flow of loops by exiting a loop, skipping an iteration etc.
Python provides three jump Statements :
1. break
2. continue
3. pass
Break Statement :
The break statement is used to terminate the loop completely when a condition becomes true.
Python
for i in range(5): if i == 3: break print(i) #output 0 1 2 Python
i = 1 while i <= 5: if i == 3: break print(i) i += 1 #output 1 2 Continue Statement :
The continue statement skips the current loop iteration and moves to the next one
Python
for i in range(5): if i == 3: continue print(i) #output 0 1 2 4 Python
i = 0 while i < 5: i += 1 if i == 3: continue print(i) #output 0 1 2 4 Pass Statement :
The pass statement is used when a block is required syntactically but no action is needed.
Python
for i in range(5): if i == 3: pass print(i) #output 0 1 2 3 4