>>> 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]