How to get the n next values of a generator in a list (python)

Use itertools.islice:

list(itertools.islice(it, n))

Leave a Comment