How to iterate over multiple lists of different lengths, but repeat the last value of a shorter list until the longest list is done?

You could make use of logical or operator to use the last element of the shorter lists:

from itertools import zip_longest
list1 = [1]
list2 = ["a", "b", "c", "d", "e", "f"]
list3 = [2]
for l1, l2, l3 in zip_longest(list1, list2, list3):
    print(l1 or list1[-1], l2, l3 or list3[-1])

Out:

1 a 2
1 b 2
1 c 2
1 d 2
1 e 2
1 f 2

You can make use of itertools.cycle, which takes a list and returns a generator, looping through the contents of the list without stop.

from itertools import cycle


list1 = [1]
list2 = [4, 5, 6, 7, 8, 9]
list3 = [2]
for l1, l2, l3 in zip(cycle(list1), list2, cycle(list3)):
     print(l1, l2, l3)

Output:

1 4 2
1 5 2
1 6 2
1 7 2
1 8 2
1 9 2

Note that we used the regular zip() instead of zip_longest(), otherwise cycle(list1) and cycle(list3) would keep generating values and we would encounter an infinite loop.

If you just have one number you'd like to repeat, you can use repeat(x) instead.

from itertools import repeat


x, y = 1, 2
list_ = [4, 5, 6, 7, 8, 9]

for l1, l2, l3 in zip(repeat(x), list_, repeat(y)):
     print(l1, l2, l3)

The unique point with cycle is that your lists will be repeated. For example, the following set of lists will generate a different output from Meyer's solution:

list1 = [1, 3]
list2 = [4, 5, 6, 7, 8, 9]
list3 = [2]

Output:

1 4 2
3 5 2
1 6 2
3 7 2
1 8 2
3 9 2