Utilizor
Contact Us

Python For Loops

Iterate over a sequence.

Examples

Iterate List

Print each fruit.

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

Loop String

Loop through characters.

for x in "banana":
  print(x)

Range Function

Loop 6 times (0 to 5).

for x in range(6):
  print(x)

Test Your Knowledge

Python Quiz

No quiz available for this topic yet.