Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
3 views
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 (106k points)
edited by

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:-

If you are looking for upskilling yourself in python you can join our Python Training and learn from the industry expert.

Related questions

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

30.5k questions

32.5k answers

500 comments

108k users

Browse Categories

...