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.
str = 'Hello World' print(str.rindex('o')) try: print(str.rindex('q')) except ValueError: print('The string "q" was not found!')
7 The string "q" was not found!