The zip_longest()
function in itertools
, extends the zip()
functions functionality.
Consider two lists A and B which are not equal in length. A has a length of 4 while B has a length of 6.
Given zip(A, B)
, the zip()
function ends after the 4th iteration as A has only 4 values. The zip_longest()
function on the other hand continues the iteration until B ends. It fills the empty values missing from A with a fill value.