1def addTwoNumbers(l1, l2):2 dummy = ListNode()3 tail = dummy4 carry = 05 while l1 or l2 or carry:6 v1 = l1.val if l1 else 07 v2 = l2.val if l2 else 08 total = v1 + v2 + carry9 carry = total // 1010 tail.next = ListNode(total % 10)11 tail = tail.next12 if l1:13 l1 = l1.next14 if l2:15 l2 = l2.next16 return dummy.next