Important Notice:

Course Content
List Manipulation in Python (Chapter-7) M3-R5
About Lesson
Traversing Elements of List:-

                किसी लिस्ट में प्रत्येक element की sequential accessing को traversing कहा जाता है।

Using ‘in’ operator inside for loop:-

           List sequence में in operation का use for loop से प्रत्येक element को iterates करने के लिए किया जाता है।

list1=[10,20,’anil’,40,’ram’,60]

for x in list1:

     print(x)

color=[‘red’,’blue’,’green’,’orange’,’purple’,’cyan’,’teal’]

if ‘purple’ in color:

     print(“Yes”)

Using range() Function:-

  यह function 2 integer number के बीच के sequence को provide करता है

for i in range(5,15):

        print(i)

Note:- list() function का use करके इसे list में बदल सकते हैं।

print(list(range(1,5)))                      # [1, 2, 3, 4]

Using while loop:-

number=[10,20,30,40,50,60]

i=0

while i<6:

    print(number[i],end=’ ‘)

    i=i+1

# 10 20 30 40 50 60

 

Traversing Elements of List:-

                Sequential accessing of each element in a list is called traversing.

Using ‘in’ operator inside for loop:-

In operation is used to iterate each element through for loop in List sequence.

list1=[10,20,’anil’,40,’ram’,60]

for x in list1:

     print(x)

color=[‘red’,’blue’,’green’,’orange’,’purple’,’cyan’,’teal’]

if ‘purple’ in color:

     print(“Yes”)

Using range() Function:-

This function provides the sequence between 2 integer numbers.

for i in range(5,15):

        print(i)

Note:- You can convert it into a list by using the list() function.

print(list(range(1,5)))                              # [1, 2, 3, 4]

Using while loop:-

number=[10,20,30,40,50,60]

i=0

while i<6:

    print(number[i],end=’ ‘)

    i=i+1

# 10 20 30 40 50 60

error: Content is protected !!