Python: zip two lists together without truncation

后端 未结 2 708
花落未央
花落未央 2020-12-06 21:09

I have two lists:

frame = [\"mercury\", \"noir\", \"silver\", \"white\" ] 
seat_colors = [ 
            \"coconut white\", \"yello\", \"black\", \"green\",          


        
2条回答
  •  鱼传尺愫
    2020-12-06 22:10

    You can use itertools.product:

    import itertools
    for item in itertools.product(frame, seat_colors):
        print item
    

    This produces the same results as your nested for loops.

提交回复
热议问题