About Lesson
rfind():-
The rfind() method finds the last occurrence of the specified value. The rfind() method returns -1 if the value is not found. The rfind() method is almost the same as the rindex() method. See example below.
Syntax:- string.rfind(value, start, end)
txt = “Hello, welcome to my world.” x = txt.rfind(“e”) print(x) # 13 |
txt = “Hello, welcome to my world.” x = txt.rfind(“e”, 5, 10) print(x) # 8 |
txt = “Hello, welcome to my world.” print(txt.rfind(“q”)) # -1 print(txt.rindex(“q”)) # valueError |