-
find() is a python function which are used to find the starting index of the substring in other string.
-It take one argument which is substring whose index is to be find.
- find() and index() both function are work same but find() is only applicable on string while index() is also apply on list.
Example-
string is "someone think"
index of 'think' is 8
string is "mytext"
index of 'hello' is -1
program-
print("Enter first string")
s1=input()
print("Enter second string")
s2=input()
print("Index value of ",s2,"in",s1,"is",s1.find(s2))
output-
Enter first string
this is bigest string
Enter second string
bigest
Index value of bigest in this is bigest string is 8
Enter first string
someone think
Enter second string
think
Index value of think in someone think is 8
-In this program, we take input of two string and check the starting index of the second string in first string by
s1.find(s2)