Python Built-in Tuple Functions
Function Description Syntax Example
any() Returns True if any element is true any(tuple) any((0, 1, 2)) -> True
all() Returns True if all elements are true all(tuple) all((1, 2, 3)) -> True
count() Counts occurrences of an element tuple.count(item) (1, 2, 2, 3).count(2) -> 2
index() Returns index of first occurrence tuple.index(item) (1, 2, 3).index(2) -> 1
len() Returns number of elements len(tuple) len((1, 2, 3)) -> 3
max() Returns maximum element max(tuple) max((1, 2, 3)) -> 3
min() Returns minimum element min(tuple) min((1, 2, 3)) -> 1
sorted() Returns sorted list of elements sorted(tuple) sorted((3, 1, 2)) -> [1, 2, 3]
sum() Returns sum of elements sum(tuple) sum((1, 2, 3)) -> 6
tuple() Converts iterable to a tuple tuple(iterable) tuple([1, 2, 3]) -> (1, 2, 3)