How to get the index of specific value in a list using sequence operator as function in Python

1 Answer

0 votes
from operator import *    
 
a = [0, 3, 1, 3, 2, 3, 4, 6, 3]     
b = ['x', 'b', 'a', 'z', 'c', 'a']
c = ['c++', 'python', 'php', 'java', 'php']
 
print(indexOf(a, 3))

print(indexOf(b, 'c'))

print(indexOf(c, 'php'))

 
'''
run:
 
1
4
2
 
'''

 



answered May 31, 2019 by avibootz
...