I’m trying to use itertools.dropwhile to only return elements from a generator that come after the third element, but I’m having a bit of trouble:
from itertools import dropwhile
it = (i for i in range(10,20))
a = dropwhile(enumerate < 3, it)
next(a)
TypeError: 'bool' object is not callable
The output I’m looking for is:
[14, 15, 16, 17, 18, 19]
Can anyone explain what is wrong with my code and provide a working solution? Thanks.
itertoolsprovides a function that does exactly what you want and more. From the Python Standard Library,