When we develope in Python, we often have to search within strings. The stringsā rindex() method is used to search the last occurrence within a string. When it fails, it raises an exception.
string.rindex(substring[, start[, end]] )
substring is the string we are searching.start and end are not mandatory and can be used to define a substring where the search should be done. Start is 0 by default.mystring = "Hello educative!"print(mystring.rindex('e'))print(mystring.rindex('e', 4, 9))