How to find the first occurrence index of a specified value in a string in Python

2 Answers

0 votes
s = "python php java c c++"

i = s.index("php")

print(i)


'''
run:
 
7
 
'''

 



answered Jan 9, 2019 by avibootz
0 votes
s = "python php java c c++"

i = s.index("p")

print(i)


'''
run:
 
0
 
'''

 



answered Jan 9, 2019 by avibootz
...