Function Details: rindex

Description


Returns the highest index in the string where substring sub is found.


Extended Description


The rindex() method finds the last occurrence of the specified substring in the string. It returns the highest index where the substring is found. If the substring is not found, it raises a ValueError. The search is performed backwards from the end of the string or from the position specified by the 'end' parameter.


Read More about rindex from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • sub: str
  • start: int
  • end: int

Return


Returns the highest index where the substring is found.


Return Type


int

Output

Explanation

This example demonstrates the basic usage of rindex(). It finds the last occurrence of 'hello'.