
find() method –
The find method returns the index of the first occurences of a substring. If not found then it returns -1.
Syntax –
string.find(sub, start, end)
sub – The sub string that you want to search in the string.
start – the start index from where the search should begin.
end – the end index before which the search should stop.
Example –
In [1]: string = "python is cool. I love python."
In [2]: string.find('python')
Out[2]: 0
In [3]: string.find('java')
Out[3]: -1
Find with start and end arguments –
In [4]: string.find('python', 10, -1)
Out[4]: 23
In [5]: string.find('java', 10, -1)
Out[5]: -1