rindex() - Searches the string for a specified value and returns the last position of where it was found

Returns the index of the last occurrence found of the specified substring.  Python will throw a ValueError exception if the substring is not found.

Example

Python
str = 'Hello World'
print(str.rindex('o'))
try:
    print(str.rindex('q'))
except ValueError:
    print('The string "q" was not found!')

Output

7
The string "q" was not found!