Python - index() - Find the position of an element
collection.index(value, start=None, end=None) is a built-in method that returns an index of a provided element in the data structure that
it was called on.
It can be called only on ordered collections like list, tuple, and string.
Method index() also accepts two optional index argument between which it will be looking for a given value.
The method returns the index of the first occurrence of the specified element.
We need to remember that if the element is not in a given collection we will receive ValueError!
Parameters:
-
value: The element whose index you want to find.
-
start (optional): The starting index to search from.
-
end (optional): The ending index (exclusive) for the search.