for each loop is used with container type of data type like list, in this example, we have a list of fruits, we are printing its type and individual values (elements) using for each loop<a.< p="" style="box-sizing: border-box;"></a.<>
# 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)
Program:
Output
need an explanation for this answer? contact us directly to get an explanation for this answer