Iterative Control Statements in Python
Iterative control statements are used to repeat a block of code multiple times.
1. FOR LOOP
Used when the number of iterations is known.
Syntax:
for variable in sequence:
statements
Example:
for i in range(1, 6):
print(i)
2. WHILE LOOP
Used when the number of iterations is not known in advance. Runs until the condition becomes
false.
Syntax:
while condition:
statements
Example:
i=1
while i <= 5:
print(i)
i += 1
3. LOOP CONTROL STATEMENTS
break - exits the loop.
continue - skips the current iteration.
pass - does nothing (placeholder).
Example for break:
for i in range(1, 10):
if i == 5:
break
print(i)
Example for continue:
for i in range(1, 6):
if i == 3:
continue
print(i)