Home >>Python Tuple Methods >Python Tuple count() Method

Python Tuple count() Method

Python Tuple count() Method

Python count() method is used to return the number of times a specified value appears in the given input tuple.

Syntax:
tuple.count(value)

Parameter Values

Parameter Description
value This is a required parameter. It defines the item to search for.
Here is an example of Python count() method:

thistuple = (1, 3, 7, 8, 7, 5, 4, 6, 8, 5)
x = thistuple.count(5)
print(x)

Output:
2
Example 2:

a = ['Abhi', 'Mickey', 'Jerry', 'Abhi', 'Cobra', 'Alpha', 'Abhi']
X = a.count("Abhi")
print(X)

Output:
3

No Sidebar ads