x : input data to check start: Optional, starting of the search position end: Optional, End of search position
returns number of matching position.
my_list=['a','b','c','b','a','d']
print("Position of first matching a : ", my_list.index('a'))
print("Position of first matching b : ", my_list.index('b'))
print("Position of first matching d : ", my_list.index('d'))
Output
Position of first matching a : 0
Position of first matching b : 1
Position of first matching d : 5
Using start and end positions
my_list=['a','b','c','b','a','d','a']
print("Position of first matching a : ", my_list.index('a',2))
print("Position of first matching b : ", my_list.index('b',1,4))
print("Position of first matching a : ", my_list.index('a',5))
Output
Position of first matching a : 4
Position of first matching b : 1
Position of first matching a : 6