Python String rindex() method

The string. rindex() method in Python returns the highest index of the substring inside the string (if found). If the substring is not found, it raises an exception.

Syntax

string.rindex(sub [,start [,end]])

Parameter

sub: This parameter represents the value to search for.

start( Optional): This parameter signifies the substring from where the search is to start and its

default value is 0.

end: This parameter signifies the substring from where to end the search and its default value is the end of the string.

Return

This method returns the highest index of the substring inside the string (if found). If the substring is not found, it raises an exception. 

Example 1

Output

Example 2

Output

Example 3

Output

Pin It on Pinterest

Share This