python find index in list of objects code example
Example 1: get index of list python
list.index(element)
Example 2: python find index by value
>>> ["foo", "bar", "baz"].index("bar")
1
Example 3: python find first occurrence in list
#iterate through list
for item in yourlist:
#if item is equal to a value
if item == 'value':
#store the item in a variable
yourvar = item
#break out of loop
break
Example 4: get index of all element in list python
indices = [i for i, x in enumerate(my_list) if x == "whatever"]