How to find number of elements in a list in Python?

To find the number of elements in a list, you can use the built-in len() function. Len() function can be used to find the length of objects like string, bytes, tuple, list, etc. Let’s see an example to find the count of elements in a list.

# Finding number of elements in a list

# A list
list_1 = ["a", "b", 1, 2, "e", "f"]

# Use len() to find the number of elements
print( len(list_1) )

Result

6
find number of elements in a list in Python

More tips on lists

Reference


Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.