why?


  • 0
    Z

    class Solution(object):
    def addTwoNumbers(self, l1, l2):
    root=n=ListNode(0)
    add=0
    while l1 or l2:
    if l1 or l2:
    n.next=ListNode((l1.val+l2.val+add)%10)
    add=(l1.val+l2.val+add)/10
    n=n.next
    l1=l1.next
    l2=l2.next
    return root.next

    Line 13: AttributeError: 'NoneType' object has no attribute 'val'
    Last executed input:
    [1,8]
    [0]

    why?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.