Take for example I have:
list1 = [0, 1, 2, 3]
list2 = [8, 7, 1, 7]
list3 = [1, 2, 3, 4]
combinedlist=[]
How do I ensure that the values will add up together in their respective rows such that the output for combinedlist will be:
[9, 10, 6, 14]
list1 = [0, 1, 2, 3]
list2 = [8, 7, 1, 7]
list3 = [1, 2, 3, 4]
out = [sum(v) for v in zip(list1, list2, list3)]
print(out)
Prints:
[9, 10, 6, 14]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With