Iterate Through Two Lists in Parallel Python Using itertools.zip_longest()
(Last Updated On: 28/03/2023)
Python Program to Iterate Through Two Lists in Parallel Using itertools.zip_longest()
# Iterate Through Two Lists in Parallel itertools.zip_longest() in python
# Python program to iterate
# over 3 lists using itertools.zip_longest
import itertools
num = [1, 2, 3]
color = ['red', 'while', 'black']
value = [123, 456]
# iterates over 3 lists and till all are exhausted
for (a, b, c) in itertools.zip_longest(num, color, value):
print (a, b, c)