Find index of a item in list in Python

In python, index function can be used to identify the first index of the value in list. If the list does not contain the item, then value error is thrown. index function also takes start and stop argument that can be used to identify subsequent occurrences of the given value

When list contains duplicates, first index is returned. Use start and stop argument to identify subsequent indexes.

Syntax
List.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.


Example 1 :
cars = ["Mercedes Benz","Honda","Audi", "Volkswagen"]
cars.index("Audi")
cars.index("Tesla")

Output
2
Value Error



Example 2:
cars = ["Mercedes Benz","Honda","Audi", "Volkswagen","Audi"]
cars.index("Audi",3)

Output
4