0

What I have:

first = [1,2,3]
second = [1,2,3,4]

What I want:

third = [2,4,6,4]

first + second = third

I've tryed using numpy and zips but they all stop after the smallest list is complete.

1 Answers1

0
from itertools import zip_longest


first = [1,2,3]
second = [1,2,3,4]
third = []

for i,z in zip_longest(first,second):
    if i  != None:
        third.append(i+z)
    else:
        a = 0 
        third.append(a+z)
print(third)

Here hope you like it

INGl0R1AM0R1
  • 1,532
  • 5
  • 16