In Python, Tuple methods are built-in functions that we can use to perform different operations on tuples. These methods provides a convenient way for manipulating and analyzing tuple data.
Since tuple is an immutable collection of elements, there are only a few built-in methods available for us to work with. Unlike lists, we cannot add, remove, or sort elements in a tuple once it's created.
The only two built-in methods that tuples support are:
We are now going to discuss these methods with the help of examples:
The count() method is a built-in Python method that allow us to count the occurrence of the specified element in a tuple. This method takes a single argument as the element to be counted and returns its occurrence in the given tuple.

The syntax of the count() method is shown below:
Parameter:
Return:
We are now going to look at a simple example showing the use of the tuple's count() method in Python.
Output:
Tuple 1: (1, 3, 4, 5, 2, 4, 6)
Count of 4: 2
Tuple 2: ('India', 'USA', 'France', 'USA', 'Germany', 'India', 'India', 'Brazil', 'Japan')
Count of India: 3
Explanation:
Here, we have used the count() method to find the total occurrences of the specified elements in the given tuples.
Let us now see another example showing the way of counting nested tuples and lists in Tuples.
Output:
Given Tuple: ((4, 5), 1, (4, 5), [4, 5], (2,), 4, 5) Count of (4, 5): 2 Count of [4, 5]: 1
Explanation:
Here, we have used the count() method to find the total occurrence of the specified tuple and list in the given tuple.
The index() method is a built-in Python method allows us to search for a specified element in the tuple and return its position. We can also select an optional range in order to search a particular region in the tuple.

The syntax of the index() method is shown below:
Parameter:
Return:
We are now going to see a simple example to understand the working of the tuple's index() method in Python.
Output:
Given Tuple: ('orange', 'apple', 'banana', 'mango', 'apple', 'melon', 'cherries', 'grapes')
First occurrence of 'apple': 1
First occurrence of 'apple' after 3rd index: 4
Explanation:
Here, we have used the index() method to find the first appearance of the specified elements in the given tuple.
Let us see an example showing what will happen if the element does not exist in the given tuple.
Output:
ValueError: tuple.index(x): x not in tuple
Explanation:
Here, we can observe that the index() method has raised the ValueError exception as the specified element is not found in the given tuple.
We request you to subscribe our newsletter for upcoming updates.