Python Tuple count() Method

Last Updated : 11 Apr 2026

In Python, the count() method is a tuple method used to count the occurrence of an element in the tuple. It returns the occurrence of the element passed during call.

This method takes a parameter which represents the element that the user wants to be counted and returns an error if the parameter is missing.

If the specified item is missing in the tuple, it simply returns 0.

Syntax of count() Method

The following is the syntax of the tuple count() method:

Parameters:

  • element (required): This parameter represents the element to be counted.

Return:

  • It returns the occurrence of the element.
  • In case, the specified element is missing in the tuple, it simply returns 0.

Examples of Tuple count()

Let's see some examples of the count() method to understand it's functionality.

Example 1: Working of the count() method

The following example displays the working of the count() method in Python:

Example

Execute Now

Output:

Tuple 1: (2, 4, 6, 8, 10)
Occurrences of 2: 1
Tuple 2: (2, 4, 6, 8, 10, 2)
Occurrences of 2: 2

Explanation:

In this example, we are given a tuple consisting of some elements. We used the count() method to return the occurrence of the specified elements in the given tuple.

Example 2: If Specified Element is Missing

If the count element is missing, it simply returns 0 except any error or exception. Let's understand this using the below example:

Example

Execute Now

Output:

Our Tuple: (2, 4, 6, 8, 10)
Occurrences of 12: 0

Explanation:

In the above example, we are given a tuple consisting of some elements. We used the count() method to count the occurrence of the specified element. Since the element does not exist in the tuple, it returns 0.

Example 3: Counting Special Characters in the Tuple

Elements can be of any type (special chars, spaces, etc.) and the count() method works for all. Let us understand this using the below example which returns occurrences of an empty string.

Example

Execute Now

Output:

Given Tuple: (12, 4, 6, 8, 10, ' ', ' ', ' ', '@', '@', '$', '@', ' ')
Occurrences of character ' ': 4
Occurrences of character '@': 3

Explanation:

Here, we are given tuple consisting of the elements including spaces and special characters. We used the count() method to count the total occurrence of the spaces and special characters in the given tuple.