tuple.count()
tuple.count() is a Python method in the Tuple Methods category. Returns the number of occurrences of x in the tuple. The syntax is tuple.count(x). Parameters: x — value to count. Returns: Integer. A typical example: t = (1, 2, 2, 3)
t.count(2) # 2
t.count(4) # 0. A close sibling is tuple.index(), which returns the index of the first occurrence of x. Raises ValueError if not found. More about this category: Tuple operations — count, index, and sequence utilities. For a broader walkthrough, read the Tuple Methods guide. Related Tuple Methods entries: tuple.index(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try tuple.count() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.