How can i add 2 numbers in a List.
I am trying to add 2 numbers in an array, it just shows None on the response box. The code is looking thus :
def add2NumberArrays(a,b):
res = []
for i in range(0,len(a)):
return res.append(a[i] + b[i])
a = [4,4,7]
b = [2,1,2]
print(add2NumberArrays(a,b))
Why does this return none? Please help.
Edits
My code looks thus :
def add2NumberArrays(a,b):
for i in range(0,len(a)):
res = []
ans = res.append(a[i]+b[i])
return ans
a = [4,4,7]
b = [2,1,2]
print(add2NumberArrays(a,b))