(self, l1, l2)
| 10 | |
| 11 | class Solution(object): |
| 12 | def addTwoNumbers(self, l1, l2): |
| 13 | pNode = ListNode(0) |
| 14 | pHead = pNode |
| 15 | val = 0 |
| 16 | while l1 or l2 or val: |
| 17 | if l1: |
| 18 | val += l1.val |
| 19 | l1 = l1.next |
| 20 | if l2: |
| 21 | val += l2.val |
| 22 | l2 = l2.next |
| 23 | pNode.next = ListNode(val % 10) |
| 24 | val /= 10 |
| 25 | pNode = pNode.next |
| 26 | return pHead.next |