For Loop in Python
A for loop is used to iterate over a sequence such as a list, string, or range.
📌 Best when the number of iterations is known.
Basic Example
for i in range(5):
print(i)
Looping through a List
fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)
Looping through a String
for char in "Python":
print(char)
Practice
- Print numbers from 1 to 10
- Print each character of your name