I want to find the position (or index) of the last occurrence of a certain substring in given input string str.
str
For example, suppose the input string is
Use the str.rindex method.
str.rindex
>>> 'hello'.rindex('l') 3 >>> 'hello'.index('l') 2