Python count items in the list

In this tutorial, we will see how to count items inlist in python


Count total items in the list

You can use len() function to count items in the list.

Let’s understand with the help of example.

Output:

List: [1, 2, 3, 4] Length of list1: 4

Count occurence of each element in the list

Output:

List: [1, 2, 3, 4, 1, 4, 3, 2, 2, 1, 5] Count of 2 in list1 3

That’s all about Python count items in the list.

Was this post helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *