Back to Module 3

Loops

Loops repeat a block of code for each item in an iterable.

for loops

words = ["read", "code", "repeat"]

for w in words:
    print(w)
for w in words:
    if "e" in w:
        print(w)

while loops

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

Next: Exercises