The simplest approach, IMHO, would be to just iterate over the string backwards and compare each character:

def myrfind(text, aChar):
    for i in range(len(text) - 1, -1, -1):
        if text[i]  == aChar:
            return i
    return -1
Answer from Mureinik on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_string_rfind.asp
Python String rfind() Method
Python Examples Python Compiler ... Plan Python Interview Q&A Python Training ... The rfind() method finds the last occurrence of the specified value....
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ string โ€บ rfind
Python String rfind()
The rfind() method returns the highest index of the substring (if found). If not found, it returns -1.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-string-rfind-method
Python String rfind() Method - GeeksforGeeks
February 21, 2025 - Python String rfind() method returns the rightmost index of the substring if found in the given string.
๐ŸŒ
Python Reference
python-reference.readthedocs.io โ€บ en โ€บ latest โ€บ docs โ€บ str โ€บ rfind.html
rfind โ€” Python Reference (The Right Way) 0.1 documentation
Returns the index of the last occurrence of the string searched for. ... Required. The string searched for. ... Optional. Search start position. ... Optional. Search end position. ... Returns -1 if sub is not found. The rfind() method should be used only if you need to know the position of sub.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ string_rfind.htm
Python String rfind() Method
The Python String rfind() method searches for the starting index of a last occurrence of a specified substring is found in an original string. Unlike the rindex() method, which raises an exception if the substring is not present, this method returns
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python โ€บ strings โ€บ .rfind()
Python | Strings | .rfind() | Codecademy
October 6, 2023 - .rfind() searches a given string for a substring starting from index 0, or alternatively, from the ith index to jth index (where i < j). The method returns the starting index of the last occurrence of the substring.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ rfind() in python
rfind() in Python | rfind() Function in Python - Scaler Topics
June 15, 2022 - In Python, the rfind() method returns the index of the last occurrence of a substring in the given string, and if not found, then it returns -1.
Find elsewhere
๐ŸŒ
Learn By Example
learnbyexample.org โ€บ python-string-rfind-method
Python String rfind() Method - Learn By Example
April 20, 2020 - Python ยท Searches the string for a given substring, starting from the right ยท The rfind() method searches for the last occurrence of the specified substring sub and returns its index.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ standard-library โ€บ str โ€บ rfind
Python str rfind() - Find Substring Reverse | Vultr Docs
December 23, 2024 - The str.rfind() method in Python is an invaluable tool for searching for substrings within a string from the end, making it ideal for instances where you need to find the position of the last occurrence of a specific character or sequence of ...
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ python-rfind
Python rfind
November 14, 2015 - The Python rfind method is used to return the index position of the last occurrence of a specified string. The rfind method returns -1 if the specified string is not found.
๐ŸŒ
Beautiful Soup
tedboy.github.io โ€บ python_stdlib โ€บ generated โ€บ generated โ€บ string.rfind.html
string.rfind() โ€” Python Standard Library
string.rfind(s, sub[, start[, end]]) โ†’ int[source]ยถ ยท Return the highest index in s where substring sub is found, such that sub is contained within s[start,end]. Optional arguments start and end are interpreted as in slice notation.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-string-methods-set-1-find-rfind-startwith-endwith-islower-isupper-lower-upper-swapcase-title
Python String Methods - Set 1 (find, rfind, startwith, endwith, islower, isupper, lower, upper, swapcase & title) - GeeksforGeeks
July 23, 2025 - str = "geeksforgeeks is for geeks" s = "geeks" # using find() to find first occurrence of s print ("The first occurrence of s is at : ", end="") print (str.find( s, 4) ) # using rfind() to find last occurrence of s print ("The last occurrence of s is at : ", end="") print ( str.rfind( s, 4) )
๐ŸŒ
TutorialKart
tutorialkart.com โ€บ python โ€บ python-string-rfind
Python String rfind() - Examples
April 3, 2023 - Python String.rfind() method returns the index of last occurrence of specified value in given string. The search for given value in this string happens from
๐ŸŒ
Learn eTutorials
learnetutorials.com โ€บ python โ€บ methods โ€บ rfind
Python rfind() Methods with Examples | Learn eTutorials
The rfind() function in python helps to return the highest index means the last occurrence of the given substring from the original string.
๐ŸŒ
Code.mu
code.mu โ€บ en โ€บ python โ€บ manual โ€บ string โ€บ rfind
The rfind method - Index of Last Match of Substring in String in Python
The rfind method returns the index of the matching substring from the end of a string in Python. If the substring is not found, the method returns the number -1.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-the-stringrfind-method-in-python
What is the string.rfind method in Python?
The rfind method in Python returns the index of the last occurrence of a substring in a string.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ what-is-rfind-in-python
What is rfind() in Python?
The rfind() method in Python returns the highest index of the specified substring if that substring is found in a string.
๐ŸŒ
datagy
datagy.io โ€บ home โ€บ python posts โ€บ python strings โ€บ python rfind: find index of last substring in string
Python rfind: Find Index of Last Substring in String โ€ข datagy
December 19, 2022 - Use the Python rfind method to find the last, or right-most, index of a substring in a Python string, including the difference to rindex.
๐ŸŒ
Dive into Python
diveintopython.org โ€บ home โ€บ functions & methods โ€บ string methods โ€บ rfind()
rfind() in Python - String Methods with Examples
The rfind() method in Python is a string method that is used to find the last occurrence of a specified substring within a string. It returns the highest index of the substring within the string.