Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the difference between zip_longest and zip in python

Shulou Source: shulou.com Published: 2022-06-03 15:18:05 10月02日 Update

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.

Tags: Sequence content analysis longest consistent professional small and medium rich in content examples that is articles more knowledge articles results industry perspective information channels length Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB MySQL vpn Shulou Information