liveBook · Manning

Find

find is a Python string method that returns the lowest index of a specified substring, or -1 when the substring is absent.

How 2 Manning books explain it

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.

Read how Python How-To explains find →

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 →

Also covered in

What to know first

Related concepts

Questions about find

What is find?

find is a Python string method that returns the lowest index of a specified substring, or -1 when the substring is absent.

Which Manning books explain find?

Python How-To and Get Programming: Learn to code with Python.

What should I know before learning find?

Manning books that teach find usually introduce ValueError first.

What is the difference between find and index?

find is a Python string method that returns the lowest index of a specified substring, or -1 when the substring is absent. index is a Python sequence method that returns the zero-based position of the first matching value or substring and raises ValueError when none is found.

What is find part of?

Find is part of __str__. __str__ is a Python special method that returns an object's informal, human-readable string representation.

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.