title: String Find Method
String Find Method
There are two options for finding a substring within a string in Python,
Each will return the position that the substring is found at. The difference between the two is that
find() returns the lowest position, and
rfind() returns the highest position.
Optional start and end arguments can be provided to limit the search for the substring to within portions of the string.
>>> string = "Don't you call me a mindless philosopher, you overweight glob of grease!" >>> string.find('you') 6 >>> string.rfind('you') 42
If the substring is not found, -1 is returned.
>>> string = "Don't you call me a mindless philosopher, you overweight glob of grease!" >>> string.find('you', 43) # find 'you' in string anywhere from position 43 to the end of the string -1
String methods documentation.