Home >>Python String Methods >Python String rfind() Method
Python string rfind() method is used to find the last occurrence of the specified value. It will return -1 if the specified value is not found in the given string. It is almost the same as the rindex() method.
Syntax:string.rfind(value, start, end)
Parameter | Description |
---|---|
value | This is a required parameter. It defines the value to search for. |
start | This is an optional parameter. It defines where to start the search. |
end | This is an optional parameter. It defines where to end the search. |
txt = "Hi everyone. I'm Jerry."
x = txt.rfind("Jerry")
print(x)
txt = "Hi everyone. I'm Jerry."
x = txt.rfind("Jerry", 5, 15)
print(x)