In this lesson, you’ll learn how loops allow you to repeat actions in your program multiple times. Loops are an essential tool in programming.
A loop is a programming structure that repeats a block of code a certain number of times or until a condition is met. Below is an example of a simple loop:
Example in Python:
for i in range(5):
print("This is loop iteration", i)
Try running the loop above in Python to see how it works. The loop will print the statement multiple times.
What will the following Python code output?
for i in range(3): print(i)
© 2025 Ocean Explorer | All Rights Reserved