The rfind() method returns the highest index where the substring is found in the str string. Otherwise, it returns -1.
Example
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
str1 = "Have a nice day....wow!!!"
str2 = "day"
print (str1.rfind(str2))
print (str1.rfind(str2, 0, 10))
Output:
12
-1
Syntax
str.rfind(sub[, start[, end]] )
Parameters
Name | Description |
sub | It’s the substring to be searched in the str string. |
Return Value
It returns the highest index of the substring with an integer value.