• Register
110 points
7

In this tutorial ,we ,ll go over each item in list with python.Listing is basically an order data structure that enables us to store and manipulate data. Listing in python is used to store more than one piece of data at a time.There are methods,Today I will show you a comparison of all the different methods and their performance.In our website Kodlogs we will see how many methods we list in python.

1.Python range( ) method
2.List Comprehension method
3.Enumerate ( ) method
4.For Loop method 
5.While Loop method
6.Numpy module method
7.Lambda ( ) method

Syntax:
For Loop
for var_name in input _list_name:
Lambda
lambda parameters :expression 
Enumerate 
Enumerate (iterable,start_index)
While Loop
while (condition):
    statement
     update_expression

Example

list = [11, 13, 15, 17,19]
 
for i in list:
    print(i)

o/p
11
13
15
17
19

Example


list = [11,13,15, 17,19]
length = len(list)
for i in range(length):
    print(list[i])
                         OUTPUT
11
13
15
17
19

Example


list = [11, 13,15,17, 19]
 
length = len(list)
i = 0
 
while i < length:
    print(list[i])
    i += 1
                    OUTPUT
11 
13
15
17
19

Exampe

list = [11, 13, 15, 17,19]
 
for i, val in enumerate(list):
    print (i, ",",val)
                             OUTPUT
   

0,11
1,13
2,15
3,17
4,19

 

110 points
7