Javatpoint Logo
Javatpoint Logo

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.

Signature

Parameters

x: element to be counted.

Return

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.

Output:

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.

Output:

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.

Output:

value is duplicate
count of p : 2

Next TopicPython Lists





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA