find index of all elements in list python code example
Example 1: get all indices of a value in list python
indices = [i for i, x in enumerate(my_list) if x == "whatever"]
Example 2: get index of list python
list.index(element)
Example 3: python index for all matches
indices = list(filter(lambda x: x == 'whatever', my_list))
Example 4: Finding index of an item list
>>> ["foo", "bar", "baz"].index("bar")
1
Example 5: find index of elem list python
First index of element "Ok" in the list : 1