How to return the index of the first occurrence of specific item in a list with Python

1 Answer

0 votes
lst = ['a', 'b', 'c', 'b', 'e', 'b', 'g'];

i = lst.index('b')

print(lst)
print(i)


    
'''
run:
    
['a', 'b', 'c', 'b', 'e', 'b', 'g']
1

'''

 



answered Jun 23, 2020 by avibootz
...