Python for each loop example: Here, we are going to actualize a program that will demonstrate examples/utilization of for each loop.
for each loop is utilized with compartment kind of information type like a rundown, in this example, we have a rundown
of natural products, we are printing its sort and individual qualities (components) utilizing for each loop.
Recommended Tutorial On: Python: Demonstrate an Example for Loop
Program:
# declare and initialize a list
fruits = ["apple","mango","guava","grapes","pinapple"]
# pritning type of fruits
print (type(fruits))
# printing value
for fruit in fruits:
print(fruit)
Output:
<class 'list'>
apple
mango
guava
grapes
pinapple