Combining lists in python

前端 未结 2 1222
陌清茗
陌清茗 2021-01-16 07:28

I am trying to combine 2 lists and want to form combinations.

a = [\'ibm\',\'dell\']
b = [\'strength\',\'weekness\']

I want to form combina

2条回答
  •  天涯浪人
    2021-01-16 08:01

    For a Cartesian product, you want itertools.product() instead of combinations.

    A nested for-loop would also work:

    for x in a:
        for y in b:
            c = a + b
            print(c)
    

提交回复
热议问题