Count and Index
Count tells you how many of a given element is in the tuple.
tup = tuple('mississippi') # each element of this tuple is a letter print(tup.count('i')) # prints 4
Index returns the index of the first occurrence of a given element in the tuple.
tup = tuple('mississippi') # each element of this tuple is a letter print(tup.index('s')) # prints 2
View on GitHub
Magic Tuple Number
A magic tuple number for a given element is the index of the given element’s first occurrence in the tuple TIMES the number of occurrences of the given element in the tuple. Given an element and a tuple, return the magic tuple number. If the element does not exist in the tuple, return -1.