Warm tip: This article is reproduced from serverfault.com, please click

Priniting 4 lists together, unequal number of elements

发布于 2020-12-01 13:22:27

If there are 4 lists

items = []
item_links = []
prices = []
images =[]

Is there a way to print these lists together? I mean, the first item of 1st list together with the first element of the third and fourth list. Thanks.

Questioner
Abhishek Rai
Viewed
0
Jason Yang 2020-12-01 21:26:28

Use zip

for item, link, price, image in zip(items, item_links, prices, images):
    print(item, link, price, image)