🐍 Python Loops

Loops let you repeat actions until a condition is met or you finish iterating over a collection.

🖥️ Example 1: for Loop

The for loop is used to iterate over a sequence like a list or range.

Output will appear here...

🖥️ Example 2: while Loop

while loops keep running as long as the condition is True.

Output will appear here...

🖥️ Example 3: Loop with break and continue

break stops the loop early, continue skips to the next iteration.

Output will appear here...
💡 Tip: Be careful with infinite loops in while loops! Always make sure the condition can become False.

📷 Python Loops Visualized

for loop example while loop example break and continue example