I have been going through the questions on iteration through lists of unequal lengths, like this one, but I have been unable to find one which addresses my exact requirements.
I have two lists of unequal lengths:
list_1 = ["dog", "cat"]
list_2 = ["girl", "boy", "man", "woman"]
if I want to iterate through the lists of different lengths, I can use itertools zip-longest function as follows
for pet, human in zip_longest(list_1, list_2):
print(pet, human)
The output I get is as follows:
dog girl
cat boy
None man
None woman
Question: What would I do if I wanted the iterator to output the following:
dog girl
dog boy
dog man
dog woman
cat girl
cat boy
cat man
cat woman
That, is in the iteration, I want to "combine" each element of list_1 to each element of list_2. What would I do?