Home >>Python String Methods >Python String rindex() Method
Python String rindex() Method in python works almost the same as the rfind() method. It returns the last index of the specified value where the substring str is found, or raises an exception if the value is not found.
Syntax:string.rindex(value, start, end)
Parameter | Description |
---|---|
value | It is Required the substring to be searched |
start | It is Optional. Where the index to start searching. Its default value is 0. |
end | It is Optional. Where to stop the search. |
xt = "Hi, How are you."
z = txt.rindex("are")
print(z)
rind = "Hello, welcome to phptpoint."
print(rind.rfind("q"))
print(rind.rindex("q"))