# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution(object):
    def addTwoNumbers(self, l1, l2):
        carry = 0
        addArray = []
    
        while (l1 is not None or l2 is not None):
            data1 = 0 if l1 is None else l1.val
            data2 = 0 if l2 is None else l2.val
    
            addition = data1 + data2 + carry
            carry = addition/10
            addition %= 10
            addArray.append(addition)
            if l1 is not None:
                l1 = l1.next
            if l2 is not None:
                l2 = l2.next
    
        if carry != 0:
            addArray.append(carry)
        
        return addArray
            