Files
Mastering-Python-2e-code_2/CH_05_functional_programming/T_12_dropwhile_takewhile.rst
T
2022-05-05 18:25:55 +02:00

10 lines
193 B
ReStructuredText

>>> import itertools
>>> list(itertools.dropwhile(lambda x: x <= 3, [1, 3, 5, 4, 2]))
[5, 4, 2]
>>> import itertools
>>> list(itertools.takewhile(lambda x: x <= 3, [1, 3, 5, 4, 2]))
[1, 3]