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

1 Answer

0 votes
s = "c++ c php python golang python nodejs"
 
pos = s.rfind("python")
           
if (pos != -1):
    print(pos, s[pos])
else:
    print("not found")
 
   
  
'''
run:

24 p
  
'''

 



answered Feb 21, 2020 by avibootz
...