A for loop is used to repeat a block of code multiple times.
Syntax:
for i in range(5):
print(i)
Output:
0
1
2
3
4
Explanation:
- for – Used to start a loop.
- i – Variable.
- range(5) – Generates numbers from 0 to 4.
- print(i) – Prints each number.
Top comments (0)