Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

l1 =[]

def f(a):
if a ==0:
return l1
else:
digit = a%10
l1.append(digit)
return f(a//10)
a =int(input("enter the value of a\n"))
f(a)

l2 =[]
def g(b):
if b ==0:
return l2
else:
digit =b%10
l2.append(digit)
return g(b//10)
b =int(input("enter the value of b\n"))
g(b)

m = len(l1)
n = len(l2)
x = m-n
def h(x):
if x == 0:
return 0
elif x>0:
l2.append(0)
return h(x-1)
elif x<0:
l1.append(0)
return h(x+1)
h(x)

lf =[]
x =0
a =0
y= len(l1)-1
z = len(l1)

def check(y):
if l1[y]+l2[y]>10:
return lf.append((l1[y]+l2[y])//10)

def add(x):
global a
if x ==z:
return 1
elif x==0:
lf.append((l1[x]+l2[x])%10)
return add(x+1)
elif x>0:
a =(l1[x-1]+l2[x-1]+a)//10
lf.append((l1[x]+l2[x]+a)%10)
return add(x+1)
add(x)
check(y)
lf.reverse()
print(lf)

You might also like