Find the Index of Last Occurrence of a Substring in a String using Python

rfind method

text = '123 456 56 78'
idx = text.rfind('56')

print(idx)  # 8

Leave a Comment

Cancel reply

Your email address will not be published.