Python String rindex() Method
Returns the index of the last occurrence found of the specified substring. Python will
ValueError exception if the substring is not found.
string.rindex(value, start, end)
||Required. The string to search for|
||Optional. The index in the string at which to start the search. The deffault is None meaning the start of the string.|
||Optional. The index in the string at which to stop the search. The default is None meaning the end of the string.|
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!