Search a string from right using rindex in Python
Search a substring from the right of a string
rindex
method also does the search for a substring
from the end of a string like rfind. It has
the following syntax.
s.rindex(sub [, start [, end]])
Like rfind, but raises ValueError
if not found instead of
returning -1
.
searchStr = "Red Blue Violet Green Blue Yellow Black"
print searchStr.rindex("Blue")
searchStr = "Red Blue Violet Green Blue Yellow Black"
print searchStr.rindex("Blue",1,18)
The code above generates the following result.