Example 1: python find in list
'Checking if something is inside'
3 in [1, 2, 3]
'Filtering a collection'
matches = [x for x in lst if fulfills_some_condition(x)]
matches = filter(fulfills_some_condition, lst)
matches = (x for x in lst if x > 6)
'Finding the first occurrence'
next(x for x in lst if ...)
next((x for x in lst if ...), [default value])
'Finding the location of an item'
[1,2,3].index(2)
[1,2,3,2].index(2)
[1,2,3].index(4)
[i for i,x in enumerate([1,2,3,2]) if x==2]
Example 2: python find index of first matching element in a list
list.index(element, start, end)
my_list = [1, 2, 3, 4, 5, 6, 7, 8, 42, 9, 10]
my_list.index(42)
--> 8
Example 3: identify list elements python
streaming = ['netflix', 'hulu', 'disney+', 'appletv+']
index = streaming.index('disney+')
print('The index of disney+ is:', index)
Example 4: find an index of an item in a list python
list = ['apples', 'bannas', 'grapes']
Index_Number_For_Bannas = list.index('apples')
print(list[Index_Number_For_Bannas])
Example 5: how to index lists in python
list = ['bananas', 'apples', 'watermellon']
print(list[1])