Code: Select all
#For loop
for num in range(1, 6):
print("Example", num)Example 2
Code: Select all
fruits = ['apple', 'banana', 'cherry']
for fruit in fruits:
print(fruit)Sometimes you want both the index and the value:
Code: Select all
colors = ['red', 'green', 'blue']
for index, color in enumerate(colors):
print(index, color)