从 2 个列表同时打印

And*_*Hou 0 for-loop list python-3.x

假设有以下 2 个列表:

l1 = ['a', 'b', 'c', 'd', 'e']
l2 = ['f', 'g', 'h', 'i']
Run Code Online (Sandbox Code Playgroud)

我正在寻找以下输出

a f
b g
c h
d i
e
Run Code Online (Sandbox Code Playgroud)

这是我尝试过的

for x, y in l1, l2:
    print(x, y)
Run Code Online (Sandbox Code Playgroud)

但这有太多项目要解压,有人知道我如何获得所需的输出吗?

zvi*_*zvi 5

使用 python zip_longest

from itertools import zip_longest

l1 = ['a', 'b', 'c', 'd', 'e']
l2 = ['f', 'g', 'h', 'i']

print (zip_longest (l1, l2, fillvalue = ''))
Run Code Online (Sandbox Code Playgroud)