What is the list count() Method?

list count() function in Python is a built-in function that lets you count the occurrence of an element in a list. It returns the count of how many times an element is present in a list.

It has various applications depending on how you use it. For example: If the count of any element is greater than 1 that means there are duplicate values. If count is 0 that means the element is not present in the list. So depending on how you use it, it can have different uses.

It only accepts one parameter, if you pass more than one parameter it raises TypeError.

Python List count() method

Python List count() method returns the count of the occurrences of a given element in a list.

Example:

Python3




#create a list
fruits = ["Apple", "Mango", "Banana", "Cherry" , "Papaya"]
# printing count using count() function
print(fruits.count("Apple"))


Output

1

Similar Reads

What is the list count() Method?

...

List count() Method Syntax

list count() function in Python is a built-in function that lets you count the occurrence of an element in a list. It returns the count of how many times an element is present in a list....

How to Use List count() Function

list_name.count(object)...

More Examples on List count() Method

The list count() function is a very easy-to-use function, you just need to call the count() function with the object list and pass the element as a parameter in the function....

Exceptions While Using Python list count() method

...

Practical Application

Let’s discuss some of the examples in different use-cases of count() method....