Example 2:
s = “CodeWindow offers IT related news“
x = s.rfind(‘q‘, 0, 33)
print(x)
Output:
-1
Explanation:
Here the character “q” is not present in the whole string. Hence it returned -1.
Note:
The difference between rindex and rfind is that rfind returns -1 if the value is not there in the string on the other hand rindex throws an error if not found.