Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
371 B
1
Indexable
Never
l1 = [9,0,1]
l2 = [9,0,1,0,1]

diff_len = max(len(l1), len(l2)) - min(len(l1), len(l2))

if len(l1) > len(l2):
    l2.extend([0] * diff_len)
if len(l2) > len(l1):
    l1.extend([0] * diff_len)

l3 = []
b = 0

for n in range(len(l1)):
    a = l1[n] + l2[n] + b
    b = 0
    if a > 9:
        a = a - 10
        b = 1
    l3.append(a)
if b > 0:
    l3.append(b)

print(l3)