Demonstration on for Loop in Python

Demonstration on for Loop in Python


 my_list=["book1","book2","book3",1,2,3]

for element in my_list:

    print(element)


Output:

book1

book2

book3

1

2

3


Another Program,

colors=["Red","Yellow","Pink","White","Blue","Purple","Black"]

for color in colors:

    print(color)

Output:

Red

Yellow

Pink

White

Blue

Purple

Black


Another Program,

fruits=["apple","banana","orange","pineapple"]

for fruit in fruits:

    print(fruit)

Output:

apple

banana

orange

pineapple




टिप्पणी पोस्ट करा

0 टिप्पण्या