The aim is to add two given lists through recursion. For example
[1,2,3] + [4,5,6] = [5,7,9]
I am getting an
int object is not iterable
error.
Here is the code:
def seqaddr(l1,l2):
if len(l1)==1:
l1[0]=l1[0]+l2[0]
return l1
else:
return seqaddr(l1[:len(l1)-1],l2[:len(l2)-1]) + list(l1.pop()+l2.pop())
seqaddr([1,2,3],[4,5,6])