+1 vote
1 view
in Python by (3.9k points)
edited by

How can I get the number of elements of a list?

Ex- 

    items = []

    items.append("one")

    items.append("two")

    items.append("three")

2 Answers

0 votes
by (10.9k points)
edited by

@Shubham,To get the number of elements in the list you can use the len() function :

items = []

items.append("one")

items.append("two")

items.append("three")

len(items)

 Output- 3

0 votes
by (107k points)

You can use the len() function to count the elements in the list:-

>>> someList=[]

>>> print len(someList)

0

You can use the following video tutorials to clear all your doubts:-

Related questions

+3 votes
2 answers
0 votes
2 answers
asked May 30, 2019 in Python by Anvi (10.2k points)
+2 votes
3 answers
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...