Find size of a list in Python

PythonServer Side ProgrammingProgramming

A list is a collection data type in Python. The elements in a list are change able and there is no specific order associated with the elements. In this article we will see how to find the length of a list in Python. Which means we have to get the count of number of elements present in the list irrespective of whether they are duplicate or not.


In the below example we take a list named as "days". We first find the length of the list using len() function. And then we add few more elements and check the length again using append() function. Finally we remove some elements using remove() function and check the length again. Please note even though the elements are duplicate the remove() function will remove only e the elements at the end of the list

days = ["Mon","Tue","Wed"]
print (len(days))
# Append some list elements
print("Now the list is: ",days)
print("Length after adding more elements: ",len(days))

# Remove some elements
print("Now the list is: ",days)
print("Length after removing elements: ",len(days))


Running the above code gives us the following result −

Now the list is: ['Mon', 'Tue', 'Wed', 'Sun', 'Mon']
Length after adding more elements: 5
Now the list is: ['Tue', 'Wed', 'Sun', 'Mon']
Length after removing elements: 4
Updated on 07-Aug-2019 08:46:48