Function Details: find
Description
Return the lowest index in the string where substring sub is found.
Extended Description
find is a Python string method that searches for first occurrence of a substring and returns its index position. Partners with index but returns -1 instead of raising error when substring not found. Works with rfind for searching from right side. Can specify optional start and end positions for targeted search range. Often used with string slicing and split operations in text processing. Essential for text parsing, data extraction, and pattern matching tasks. Creates foundation for more complex string manipulations.
Read More about find from Python Documentation
Function Signature
Module: builtins
Class: str
Parameters
Parameter List
- sub: str
- start: int
- end: int
Return
Returns the lowest index where the substring is found, or -1 if not found.
Return Type
int
Output
Explanation
This example demonstrates the basic usage of find(). It searches for 'world' in the string.