2022年7月13日 星期三

[python, list, add] How to add two lists elements

 # Add two list by using sum zip

lt1 = [6, 12, 18, 3, 6, 9]  

lt2 = [4, 8, 12, 2, 4, 6] 

result_lt = [sum(i) for i in zip(lt1, lt2 )]


Result
[10, 20, 30, 5, 10, 15]