-
Notifications
You must be signed in to change notification settings - Fork 0
/
length of list
44 lines (31 loc) · 973 Bytes
/
length of list
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#Program to find length of list
#Method number 1
list=[12,56,32,90,5]
print("The first list is : ",list)
counter=0
for i in list:
counter+=1
print("Length of first string : ",counter)
print("--------------------------------------------------------------------")
#Method number 2
list1=[]
list1.append("Anshima")
list1.append("Kanika")
list1.append("Mayank")
list1.append("Abhi")
print("The second list is : ",list1)
print("Length of second string : ",len(list1))
print("---------------------------------------------------------------------")
#Method number 3
list2=[1,2,3,4,5,6,7,8,9]
print("The third string is : ",list2)
l=len(list2)
print("Length of third string : ",l)
print("---------------------------------------------------------------------")
#Method number 4
list3 = [ 1, 4, 5, 7, 8 ]
print ("The list is : " + str(list3))
counter = 0
for i in list3:
counter = counter + 1
print ("Length of list using naive method is : " + str(counter))