Jumping statements in python
break and continue are the jumping statements in python.
Break Statement in Python is used to terminate the loop.
Syntax of break statement
break
Example of break statement in python
i=1
while(i<6):
print(i,end=' ')
i=i+1for i in range(5):
if i==3:
break
print(i,end=' ')
Output
0 1 2
Continue Statement in Python is used to skip all the remaining statements in the loop and move controls back to the top of the loop.
Syntax of continue statement in python
continue
Example of continue statement in python
for i in range(5):
if i==3:
continue
print(i,end=' ')
Output
0 1 2 4