list.index()
list.index() is a Python method in the List Methods category. Returns the index of the first occurrence of x. Raises ValueError if not found. The syntax is list.index(x, start=0, end=len(list)). Parameters: x — value to find. Returns: Index integer. A typical example: lst = [1, 2, 3, 2]
lst.index(2) # 1
lst.index(2, 2) # 3. A close sibling is list.append(), which appends an item to the end of the list. Modifies the list in place. A close sibling is list.extend(), which extends the list by appending all items from the iterable. A close sibling is list.insert(), which inserts an item at a given position. The first argument is the index. A close sibling is list.remove(), which removes the first occurrence of x from the list. Raises ValueError if not found. More about this category: List methods for sequence manipulation — append, sort, pop, extend, and more.