Python List count()

The count() method returns the number of times the specified element appears in the list.

Example


Syntax of List count()

The syntax of the count() method is:

list.count(element)

count() Parameters

The count() method takes a single argument:

  • element - the element to be counted

Return value from count()

The count() method returns the number of times element appears in the list.


Example 1: Use of count()

Output

The count of i is: 2
The count of p is: 0

Example 2: Count Tuple and List Elements Inside List

Output

The count of ('a', 'b') is: 2
The count of [3, 4] is: 1