Generator Pythona w pętli
from itertools import takewhile
i = iter(range(10))
for x in takewhile({some logic}, i):
# do stuff
Expert--;
from itertools import takewhile
i = iter(range(10))
for x in takewhile({some logic}, i):
# do stuff