Python List index() method

The list.index () method in Python returns the position at the first occurrence of the specified value.

Syntax

Parameter

element – This parameter represents the element whose lowest index will be returned.

start (Optional) – It signifies the position from where the search begins.

end (Optional) – This parameter signifies the position from where the search ends.

Return

This function returns a zero-based index in the list of the first item whose value is equal to x or raises a ValueError if there is no such item.

Example 1

Output

Example 2

Output

Pin It on Pinterest

Share This