class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next

class Solution:
    def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
        start = ListNode()
        current = start
        carry = 0
        
        while (l1 or l2):
            val = (l1.val if l1 else 0) + (l2.val if l2 else 0) + carry
            
            if val >=10:
                carry = 1
                val = val%10
            else:
                carry = 0
            
            current.next = ListNode(val = val, next = None)
            current = current.next
            
            if l1:
                l1 = l1.next
            if l2:
                l2 = l2.next
            
        if carry > 0:
            current.next = ListNode(val=carry)
            
        return start.next