Source: π Effective Python item 36
itertools.dropwhile
This function is the opposite of itertools.takewhile
βit will skip items from an iterator until the provided function argument returns True
.
values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
less_than_seven = lambda x: x < 7
it = itertools.dropwhile(less_than_seven, values)
print(list(it))
>>>
[7, 8, 9, 10]