Element-wise addition of 2 lists?

后端 未结 16 1463
感动是毒
感动是毒 2020-11-22 07:48

I have now:

list1 = [1, 2, 3]
list2 = [4, 5, 6]

I wish to have:

[1, 2, 3]
 +  +  +         


        
16条回答
  •  借酒劲吻你
    2020-11-22 08:35

    a_list = []
    b_list = []
    for i in range(1,100):
        a_list.append(random.randint(1,100))
    
    for i in range(1,100):
        a_list.append(random.randint(101,200))
    [sum(x) for x in zip(a_list , b_list )]
    

提交回复
热议问题