How to find the index of an item in a list using Python

2 Answers

0 votes
a_list = ["python", "java", "c#"]

i = a_list.index("java")

print(i)


'''
run:

1

'''

 



answered Oct 26, 2017 by avibootz
0 votes
a_list = ["python", "java", "c#"]

for i, j in enumerate(a_list):
    if j == 'java':
        print(i)


'''
run:

1

'''

 



answered Oct 26, 2017 by avibootz
...