Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
how to make the result of this be [2,5,10,5.5]

What I have tried:

lst = [1,2,3,4]
lst1 = [1,3,7,1.5]
lsw=0
lsw=lst+lst1
print(lsw)
Posted
Updated 26-Jul-22 4:35am

1 solution

Use the zip function[^]:
final_list = [sum(value) for value in zip(lst, lst1)]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900