tuple.index()
tuple.index() is a Python method in the Tuple Methods category. Returns the index of the first occurrence of x. Raises ValueError if not found. The syntax is tuple.index(x, start=0, end=len(tuple)). Parameters: x — value to find. Returns: Index integer. A typical example: t = (1, 2, 3, 2)
t.index(2) # 1
t.index(2, 2) # 3. A close sibling is tuple.count(), which returns the number of occurrences of x in the tuple. 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.count(). 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.index() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.