Repeating Actions Efficiently
Loops allow you to iterate over collections of items or execute a block of code multiple times until a condition is met.
The for loop in Python is particularly expressive, iterating directly over elements in lists, ranges, strings, or dictionaries.
python Example
# Iterating with a for loop
technologies = ["HTML", "CSS", "JS", "Python"]
for tech in technologies:
print(f"Learning: {tech}")
# Using range()
total = 0
for i in range(1, 6):
total += i
print(f"Sum of 1 through 5 is {total}")