Python String rfind() MethodLast Updated : 31 Dec 2025 Python rfind() method finds a substring in in the string and returns the highest index. It means it returns the index of most righmost matched subtring of the string. It returns -1 if substring not found. Syntax of Python rfind(str,beg=0,end=len(str))It has the following syntax: Parameters
ReturnIt returns either index of substring or -1. Different Examples for Python String rfind() FunctionLet's see some examples of rfind() method to understand it's functionality. Example 1Let's have a simple example to implement the rfind() method. It returns highest index of the substring. Output: 16 Example 2One more example to understand the working of rfind() method. Output: 18 Example 3This method takes other three parameters including two optional. Let's provide start and end index to the method. Output: 18 6 Next TopicPython Strings |
We request you to subscribe our newsletter for upcoming updates.