- rindex() is python in-build function which are used to find the index of the substring in the given string.
- rindex() is not the applicable for list data type.
- here str is given string.
- and str1 is the substring whose index is to be find
- beg and end are the starting and ending point of given string where you want to search.
Difference between index() and rindex() in python-
Basically, both function are used to search the location of the substring in given string but
- index() start searching from the left side of the string and also applicable for list.
- and rindex() start searching from the right side of the string and not applicable for list.
string is s="This is is string"
s.index("is") will give 5
s.rindex("is") will give 8