Answers for "itertools .cycle()"

0

itertools .cycle()

def cycle(iterable):
    # cycle('ABCD') --> A B C D A B C D A B C D ...
    saved = []
    for element in iterable:
        yield element
        saved.append(element)
    while saved:
        for element in saved:
              yield element
Posted by: Guest on March-15-2021

Browse Popular Code Answers by Language