Loop Control Statements

Control statements alter the

sequential execution of a program.

These are three Types

  1. Break
  2. Continue
  3. pass

Break :

Break statement makes the program exit a loop early.

Example :

for i in range(1, 11):
  if i == 4:
    break
  print(i)

Output :

1
2
3

Continue :

Skips current loop step and moves to the next.

Example :

# Print all numbers from 1 to 5, except 3
for i in range(1, 6):
    if i == 3:  # Skip number 3
        continue
    print(i)

Output :

1  
2  
4  
5  

Pass :