Menu Close
python list count() method

In this tutorial, we are going to learn the Python List count() method. list count function in python allows us to find the count of an item, how many numbers of times appear in the list. Sometimes we need to find how many times items appear in this list.
In the previous tutorial, we have seen the Python list copy() method to create a copy of the existing.

List count() Method:

In Python, the list count() method is a built-in list method, which returns the count of the total number of times an item appears in the list.

Syntax of list count() method:

list.count(value)

Python List count() method parameter:

list count method takes a single parameter, That is item.
item:- Required. Any type ( string, number, list, tuple, etc). The value to search for.

Python List count() method example:

Example 1:

fruits = ['apple', 'banana', 'cherry','banana']
x = fruits.count('banana')

Output

2

Example 2:

mylist = ['Python', ('C', 'C++'), 'Java', ('C', 'C++'), 'JavaScript', ('C', 'C++')]
print(mylist.count(('C', 'C++')))

Output

3

Conclusion:

In this tutorial, you have learned the python list count() method. Using the list count function, you can count how many times a specific item occurs in the list.
I hope this article will help you. if you like this article please comment and share it with your friends who want to learn Python from scratch to advanced.

For More Reference:- Click Here

Python List pop() Method
Python List append() Method

Related Posts