What is the difference between zip_longest and zip in python
In this issue, Xiaobian will bring you the difference between zip_longest and zip in python. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.
Zip returns the shortest sequence, zip_longest the longest sequence.
If zip_logest encounters sequences of inconsistent length, the missing part will be filled with None.
examples
from itertools import zip_longesta = list(zip ('ABC ', range(5), [10, 20, 30, 40]))print(a)a = list(zip_longest ('ABC', range(5), [10, 20, 30, 40]))print(a) The above is what the difference between zip_longest and zip in Python is shared by everyone. If you happen to have similar doubts, please refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.