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.
The following is the syntax of the tuple count() method:
Let's see some examples of the count() method to understand it's functionality.
The following example displays the working of the count() method in Python:
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.
If the count element is missing, it simply returns 0 except any error or exception. Let's understand this using the below example:
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.
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.
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.
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India