🎓 All Courses | 📚 Python Programming Syllabus

📋 Study this course on TaskLoco
⚡ Key Concept #python-programming#loops#control-flow

Loops — Repeating Actions

For loop — iterate over sequences:

fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
    print(fruit)

for i in range(5):      # 0,1,2,3,4
    print(i)

for i in range(2, 10, 2):  # 2,4,6,8
    print(i)

While loop — repeat while condition is true:

count = 0
while count < 5:
    print(count)
    count += 1

Loop control:

for i in range(10):
    if i == 3:
        continue   # skip this iteration
    if i == 7:
        break      # exit loop entirely
    print(i)

enumerate() — loop with index:

for index, fruit in enumerate(fruits):
    print(f"{index}: {fruit}")

zip() — loop two lists together:

names = ["Alice", "Bob"]
scores = [95, 87]
for name, score in zip(names, scores):
    print(f"{name}: {score}")

YouTube • Top 10
Python Programming: For Loops & While Loops
Tap to Watch ›
📸
Google Images • Top 10
Python Programming: For Loops & While Loops
Tap to View ›

Reference:

Wikipedia: For Loop

image for linkhttps://en.wikipedia.org/wiki/For_loop

📚 Python Programming — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT