📜  python 如何对两个列表求和 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:12.130000             🧑  作者: Mango

代码示例2
list1 = [1, 2, 3]
list2 = [4, 5, 6]

# `zipped_lists` contains pairs of items from both lists.
# Create a list with the sum of each pair.
sum = [x + y for (x, y) in zip(list1, list2)] 

print(sum)
# [5, 7, 9]