# Find first index (or value) that meets condition
my_list = [2, 4, 6, 9, 10]
# Option 1. Use an iterator (does not scan all list)
y = (i for i,x in enumerate(my_list) if is_odd(x))
idx1 = next(y) # <== index of first element
y = (x for i,x in enumerate(my_list) if is_odd(x))
v1 = next(y) # <== value of first element
# Option 2. Use a list comprehension (scans all list)
idx1 = [i for i,x in enumerate(my_list) if x % 2 != 0][0]
v1 = [x for i,x in enumerate(my_list) if x % 2 != 0][0]
# Basic syntax:
list.index(element, start, end)
# Where:
# - Element is the item you're looking for in the list
# - Start is optional, and is the list index you want to start at
# - End is optional, and is the list index you want to stop searching at
# Note, Python is 0-indexed
# Example usage:
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 42, 9, 10]
my_list.index(42)
--> 8