in this tutorial, you will learn how to find the number of length or elements of a Python list.
Python len() method
With the help of the Python len()
method, you can get the number of items in an object.
len(object)
- The
len()
method takes only one parameter. - The parameter can be a
sequence
orcollection
. - Sequence –
string
,range
,tuple
,list
,bytes
- Collection –
dictionary
,set
- This function returns the length of the given object.
Finding the length of a Python List
>>> a = [1, "Hello", 54, "Python", 24, "Java"]
>>> a_length = len(a)
>>> print(a_length)
6
>>>