"""
Definition of ListNode
class ListNode(object):
    def __init__(self, val, next=None):
        self.val = val
        self.next = next
"""

class Solution:
    """
    @param l1: the first list
    @param l2: the second list
    @return: the sum list of l1 and l2 
    """
    def addLists(self, l1, l2):
        # write your code here
        carry = 0
        root = current = ListNode(-1)
        while (l1 or l2 or carry):
            v1 = v2 = 0
            if l1:
                v1 = l1.val
                l1 = l1.next
            if l2:
                v2 = l2.val
                l2 = l2.next
            carry, value = divmod(v1 + v2 + carry, 10)
            current.next = ListNode(value)
            current = current.next
            
        return root.next;
"""
Definition of ListNode
class ListNode(object):
    def __init__(self, val, next=None):
        self.val = val
        self.next = next
"""

class Solution:
    """
    @param l1: the first list
    @param l2: the second list
    @return: the sum list of l1 and l2 
    """
    def addLists(self, l1, l2):
        # write your code here
        carry = 0
        root = current = ListNode(-1)
        while (l1 or l2 or carry):
            v1 = v2 = 0
            if l1:
                v1 = l1.val
                l1 = l1.next
            if l2:
                v2 = l2.val
                l2 = l2.next
            carry, value = divmod(v1 + v2 + carry, 10)
            current.next = ListNode(value)
            current = current.next
            
        return root.next;
Definition of ListNode class ListNode(object):     def __init__(self, val, next=None):         self.val = val         self.next = next @param l1: the first list     @param l2: the second list     @return: the sum list of l1 and l2 # write your code here