str.find (sub, start, end)
sub: It`s the substring which needs to be searched in the given string.
start: Starting position where sub is needs to be checked within the string.
end: Ending position where suffix is needs to be checked within the string.
NOTE. If no start and end indexes are provided, then it defaults to 0 and length-1 as start and end indices, where end indices are not included in our search.
Returns the highest index of the substring inside the string if substring is found. Otherwise it raises an exception.
input: text = `geeks for geeks` result = text.rindex (` geeks `) output: 10 input: text =` geeks for geeks` result = text.rindex (`ge`) output: 10
Errors and exceptions:
ValueError : This error occurs when no argument string is found in the target string.
Traceback (most recent call last): File "/ home / da dc555d90806cae90a29998ea5d6266.py ", line 6, in result = text.rindex (` pawan`) ValueError: substring not found