Loops in Python

Learn how to repeat actions using for and while loops

🔁 What are Loops?

A loop allows repetitive tasks in Python. Common loop types are for and while.

📘 For Loop

for loop iterates over sequences like lists, range, etc.

for i in range(1, 6):
    print("Number:", i)

Output: Number: 1 to 5

🔄 While Loop

The while loop continues as long as the condition is true.

count = 1
while count <= 5:
    print("Count is", count)
    count += 1

⚙️ Loop Control Statements

for i in range(5):
    if i == 3:
        break
    print(i)

✅ Real-Life Examples