AlphaCodingSkills

Python - Tuple count() Method


Advertisements

The tuple count() method is used to find out the total number of occurrences of a specified element in the tuple.

Syntax


tuple.count(elem)

Parameters

elem Required. value of the element which need to be counted in the tuple.

Example:

In the below example, tuple count() method is used to find out the total number of occurrences of 50 in the tuple called MyTuple.

MyTuple = (10, 50, 50, 100, 50, 1000)

x = MyTuple.count(50)      
print(x)

Output

3

Tuples Methods