Skip to main content

count()

The count() is a method that used to count the number of occurrences of a specified element within a Python tuple. The method returns the number of times the specified element appears in the tuple.

Parameter Values

Parameter Description
element

The element to count in the tuple

Return Values

The count() method in Python returns an int representing the number of occurrences.

How to Use count() in Python

Example 1:

The count() method returns the number of times a specified value appears in a tuple.

tup = (1, 2, 3, 4, 1, 1, 2)
print(tup.count(1))

Tuple Methods