Python has the following methods that work with tuples:
any(): This method can be used to discover whether any element of a tuple is an iterable:
>>> pets = ('cat', 'dog', 'horse') >>> any(pets) >>> TRUE
count(): This method returns the number of occurrences of an item in a tuple.
This is also the only bound method, as the syntax describes: tuple.count(element). The other methods are unbound:
>>> pets = ('cat', 'dog', 'horse') >>> pets.count("cat") >>> 1
min(): This method returns the smallest element in a tuple:
>>> pets = ('cat', 'dog', 'horse') >>> min(pets) >>> 'cat'
max(): This method returns the largest element in a tuple:
>>> pets = ('cat', 'dog', 'horse') >>> max(pets) >>> 'horse'
len(): This method returns the total number of elements in a tuple:
>>> pets = ('cat', 'dog', 'horse') >>> len(pets) >>> 3
Tuples, just like strings, can be concatenated...