1
0

itertools.py 345 B

123456789101112131415
  1. from __builtins import next
  2. def zip_longest(a, b):
  3. a = iter(a)
  4. b = iter(b)
  5. while True:
  6. ai = next(a)
  7. bi = next(b)
  8. if ai is StopIteration and bi is StopIteration:
  9. break
  10. if ai is StopIteration:
  11. ai = None
  12. if bi is StopIteration:
  13. bi = None
  14. yield ai, bi