Python - String Method - find() Tutorial
It will return the index of the first occurrence of the specified value in the given string. If not found it will return -1. It is similar to the index(), the only difference is index() method will raise an exception if a specified value is not found.
Syntax-
String.find(value, start, end)
#value - It is a specified value that
needs to be searched in the given String.
#start - (Optional) It is a position to start
the search, by default, it is 0
#end - (Optional) It is a position to end search,
by default is the end of the string
Example-
str1 = "Hello Welcome to python Tutorial"
print(str1.find("python"))
print(str1.find("Python"))#case sensitive
print(str1.find("to",10,30))
print(str1.find("to",20,30))
Output-
17
-1
14
26