Python Tuple Methods
Python has two built-in methods that you can use on tuples.
1. count() | Returns the number of times a specified value occurs in a tuple |
2. index() | Searches the tuple for a specified value and returns the position of where it was found |
1. Python Tuple count() Method
The count() method returns the number of occurrences of an element in a tuple.
Syntax
tuple.count(value)
Parameter Values
value - element whose count is to be found
2. Python Tuple index() Method
The index() method finds the first occurrence of the specified value.
The index() method raises an exception if the value is not found.
Syntax
tuple.index(value)
Parameter Values
value - Required. The item to search for