Python -Generator in der Schleife

from itertools import takewhile

i = iter(range(10))
for x in takewhile({some logic}, i):
    # do stuff
Expert--;