Python String find() is an inbuilt function that returns the index of the first occurrence of the substring (if found). If not found, it returns -1.

If the start and end indexes are not provided then by default, it takes 0 and length -1 as starting and ending indexes where the ending indexes are not included in our search.

Python String find()

Python string find() function is almost the same as the  Python string index() method, and the only difference is that the index() method raises an exception if the value is not found. Python find() method is used to find the index of a substring in the string.

Syntax

The syntax for the find() method is the following.

string.find(value, start, end)

#python #python string find

Python String find: How to Find First Occurrence of SubString
2.10 GEEK