Python rindex() is an inbuilt string handling method that returns the highest index of the substring that is passed in the rindex() function as an argument. If that substring is not present in the main string, then the function throws an exception.  There are three arguments passed, first is the substring, starting and ending indexes of the main string in which we want to search. To give starting and ending indexes is optional, and if we don’t give it, 0 and length of string -1 is taken as default.

Python String rindex()

Python string function rindex() returns the last index where the substring str is found or raises the exception if no such index exists, optionally restricting the search to string[beg: end].

#python #python string rindex #rindex

Python String rindex() Method Example
1.05 GEEK