Skip to content

Instantly share code, notes, and snippets.

@Kush1101
Created October 27, 2020 12:01
Embed
What would you like to do?
from itertools import zip_longest
iter1 = [1, 2, 3, 4, 5, 6]
iter2 = [1, 4, 9, 16, 25]
iter3 = [1, 8, 27, 64, 125]
for i in zip_longest(iter1, iter2, iter3, fillvalue = 0):
print(i)
# OUTPUT
"""
(1, 1, 1)
(2, 4, 8)
(3, 9, 27)
(4, 16, 64)
(5, 25, 125)
(6, 0, 0)
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment