How to find the index of first occurrence of substring in a string with Python

1 Answer

0 votes
s = "c++ c php python golang python java"
  
index = s.find("python")
            
if (index != -1):
    print(index, s[index], s[index + 1])
else:
    print("not found")
  
    
   
'''
run:
 
10 p y
   
'''
 
  


 



answered Oct 24, 2020 by avibootz
...