Episode 9 of 29
For Loops
Learn how to iterate over sequences like lists, strings, and ranges using for loops.
For loops iterate over sequences — lists, strings, tuples, and more.
Looping Through Lists
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)Using enumerate()
colors = ["red", "green", "blue"]
for index, color in enumerate(colors):
print(index, color)Break and Continue
for num in range(10):
if num == 5:
break
if num % 2 == 0:
continue
print(num)