Python List count() Method
Python count() method returns the number of times element appears in the list. If the element is not present in the list, it returns 0. The examples and syntax is described below.
x: element to be counted.
It returns number of times x occurred in the list.
Let's see some examples of count() method to understand it's functionality.
Python List count() Method Example 1
It is a simple example to understand how a count method works.
count of p : 2
Python List count() Method Example 2
If the passed value is not present in the list, the method returns 0. See the example below.
count of b : 0
Python List count() Method Example 3
Python count() method can also be used to check whether an element is duplicate in the list or not. The below example checks the duplicacy of the element in the list.
value is duplicate count of p : 2