Python String rfind() Method
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.
sub : substring to be searched.
start (optional) : starting index to start searching.
end (optional) : end index where to search stopped.
It returns either index of substring or -1.
Let's see some examples of rfind() method to understand it's functionality.
Python String rfind() Method Example 1
Let's have a simple example to implement the rfind() method. It returns highest index of the substring.
Python String rfind() Method Example 2
One more example to understand the working of rfind() method.
Python String rfind() Method Example 3
This method takes other three parameters including two optional. Let's provide start and end index to the method.