Given two arrays.
array_1 = [1, 4, 5, 8, None, None, None]
array_2 = [7, 4, 8, 9, 5, None, None]
output:
array_3 = [1, 4, 10, 17, 8, 4, 7]
It will start from the first element of the first array and the last element of the second array and return the sum of them.
For example, (1+None)= 1
, (4+None)=4
, (5+5)= 10
, (8+9)=17
and so on.
My attempt at this problem,
array_1= [1,4,5,8,None,None,None]
array_2= [7,4,8,9,5,None,None]
for i in range (len(array_1)):
for j in range (len(array_2)-1,0,-1):
if i == None:
array_1[i]=0
elif j==None:
array_2[j]= 0
L= array_1[i]+array_2[j]
print(L)