Python Programming
- Neowep software technologies
Looping control statements:
In Python, there are three primary loop control statements:
1. break
2. continue
3. pass
break
Def:
break statement in python is used to terminate a loop prematurely.
This statement is useful when you want to stop a loop once a certain
condition is met
Example:
for i in range(1, 11):
if i == 5:
break
print(i)
continue
Def:
continue is used to skip the current iteration of a loop and move on to the
next one.
This statement is useful when you want to skip over certain values in a loop
without terminating it altogether.
Example:
for i in range(1, 11):
if i == 5:
continue
print(i)
pass
Def:
pass is a placeholder statement that does nothing.
It is used when you need to include a statement in your code for syntactical
reasons, but you do not want it to do anything.
Example:
for i in range(1, 11):
pass