get all indexes of element 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 item in list
list.index(element, start, end)
Example 3: get index of all element in list python
indices = [i for i, x in enumerate(my_list) if x == "whatever"]
Example 4: python index for all matches
indices = list(filter(lambda x: x == 'whatever', my_list))