How to find an index of all appearance of an item in a list with Python

1 Answer

0 votes
a_list = ['python', 'java', 'c#', 'python', 'c++', 'php', 'python']

for i, s in enumerate(a_list):
    if s == 'python':
        print(i)

'''
run:

0
3
6

'''

 



answered Aug 30, 2018 by avibootz

Related questions

3 answers 334 views
2 answers 259 views
1 answer 183 views
1 answer 165 views
...