Similar to the built-in function zip(), itertools.zip_longest will continue iterating beyond the end of the shorter of two iterables.
from itertools import zip_longest
a = [i for i in range(5)] # Length is 5
b = ['a', 'b', 'c', 'd', 'e', 'f', 'g'] # Length is 7
for i in zip_longest(a, b):
x...