Iteration Classes

itertools.dropwhile()

Discard the initial run of truthy predicate results, then yield the first false item and all remaining items without further predicate tests.

Formal Syntax & Structure

python syntaxpython
itertools.dropwhile(predicate, iterable, /)

Parameters & Attributes

NameTypeDescription
predicatecallablePredicate applied to each input value.
iterableiterableInput values, consumed as needed.

Return Value

iterator

The iterator result described above.

Working Example

Example Snippetpython
import itertoolsprint(list(itertools.dropwhile(lambda x:x<3,[1,3,2,4])))
Python Reference