Find
find is a Python string method that returns the lowest index of a specified substring, or -1 when the substring is absent.
Python How-To
The Python str.find method returns the lowest index at which a specified substring occurs, or -1 if it is absent.
- How it is used
- Uses string substring searches where absence should produce a testable result instead of an exception.
- How deep it goes
- Defines the return values, string-only scope, and basic conditional pattern, but does not explain implementation internals.
- Examples
- Demonstrates checking a returned index and filtering task titles, descriptions, and completion notes.
- What you can do after
- Apply it via Python strings to locate substrings and branch safely when no match exists.
Get Programming: Learn to code with Python
find is a Python string method that returns the lowest index of a specified substring or -1 when the substring is absent.
- How it is used
- Uses substring searches to inspect text and locate separators in user input.
- How deep it goes
- Explains case sensitivity, indexing, first matches, missing matches, and a slicing application, but stops short of implementation internals.
- Examples
- Demonstrates searches in "some_string" and "me myself and I", then splits names such as "Aqua Man" using a space.
- What you can do after
- Apply it to locate substrings or separators, test whether text is present, and guide string slicing.
Read how Get Programming: Learn to code with Python explains find →
Related concepts
- indexingproduces · Indexing is the organization or use of positions, keys, or lookup structures to identify and retrieve selected data or elements.
- string moduleuses · The string module is a Python standard-library module providing constants and utilities for processing text and character classes.
- __str__part of · __str__ is a Python special method that returns an object's informal, human-readable string representation.
- substringuses · A substring is a contiguous sequence of characters contained within a larger string or character sequence.
- rfindalternative to · rfind is a Python string method that returns the highest index at which a specified substring begins, or -1 if it is absent.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

