Element-wise addition of 2 lists?

后端 未结 16 1208
感动是毒
感动是毒 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:22

    It's simpler to use numpy from my opinion:

    import numpy as np
    list1=[1,2,3]
    list2=[4,5,6]
    np.add(list1,list2)
    

    Results:

    For detailed parameter information, check here: numpy.add

提交回复
热议问题