Python 3 reference · Tuple Methods

Python Tuple count() Method

Return how many times a value appears in the tuple, comparing each item with ==. Returns 0 if it never appears.

Python 3 Since 3.0

Syntax

tuple.count(value)

Parameters

ParameterDescription
value The value to count.

Return value

An int.

Examples

Count a valueTry it yourself
rolls = (6, 2, 6, 6, 1)
print(rolls.count(6), rolls.count(3))

Output

3 0
Check repeated coordinatesTry it yourself
point = (0, 0, 1)
print(point.count(0) == 2)

Output

True

Version history

VersionChange
Python 3.0Added