pocketpy/python/itertools.py
2024-08-04 14:57:59 +08:00

16 lines
339 B
Python

from pkpy import next
def zip_longest(a, b):
a = iter(a)
b = iter(b)
while True:
ai = next(a)
bi = next(b)
if ai is StopIteration and bi is StopIteration:
break
if ai is StopIteration:
ai = None
if bi is StopIteration:
bi = None
yield ai, bi