What is the String find() Method?
String find() is an in-built function in Python that is used to find the index of a substring within a given string.
It is a very easy and useful string function, that can help us find a given substring. It returns the index of the substring if it is found in the string, but if the substring is not present in the string it returns -1.
Python String find() method
Python String find() method returns the lowest index or first occurrence of the substring if it is found in a given string.
Example
Python3
# initializing a string word = 'find me if you can' # using string find() method print (word.find( 'me' )) |
Output
5
Contact Us