"""
兩個清單對應元素相加
列出常用的3種
1.zip函數配合清單推導式
2.numpy的方法sum()
3.最基本的for循環
!!!加減乘除,異曲同工
"""
a = [1, 2, 3]
b = [4, 5, 6]
# 1.zip函數配合清單推導式
result = [i + j for i, j in zip(a, b)]
print(result) # [5, 7, 9]
# 2.numpy的方法sum()
import numpy as np
result = np.sum([a, b], axis=0).tolist()
print(result) # [5, 7, 9]
# 3.最基本的for循環
result = []
for i in range(len(a)):
result.append(a[i] + b[i])
print(result) # [5, 7, 9]