
for loop?A loop lets us repeat code without writing it multiple times.
A for loop is used when we want to go through (or iterate over) a sequence of items, like numbers, letters, or elements in a list.
for variable in sequence:
# code to run each time
variable β takes each value from the sequence one by one.sequence β the collection weβre looping through (like a list or range).fruits = ["apple", "banana", "cherry"]
for fruit in fruits:
print(fruit)
π Output:
apple
banana
cherry
for letter in "Python":
print(letter)
π Output:
P
y
t
h
o
n
range()for number in range(5):
print(number)
π Output:
0
1
2
3
4
β‘ Note: range(5) gives numbers from 0 up to 4 (not including 5).
Fill out the Get Help form and our team will contact you.
We accept UPI, Debit/Credit Cards, and Net Banking.
Yes, installment options are available for selected courses.
Yes, we provide resume and interview support.