Copyright © tutorialspoint.com
This method determines if str occurs in string, or in a substring of string if starting index beg and ending index end are given.
str.find(str, beg=0 end=len(string)) |
Here is the detail of parameters:
str: specifies the string to be searched.
start : starting index, by default its 0
end : ending index, by default its equal to the lenght of the string.
It returns index if found and -1 otherwise.
#!/usr/bin/python str1 = "this is string example....wow!!!"; str2 = "exam"; print str1.find(str2); print str1.find(str2, 10); print str1.find(str2, 40); |
This will produce following result:
15 15 -1 |
Copyright © tutorialspoint.com