AttributeError by Python solution, for help


  • 0
    P

    I have a problem with "AttributeError" in Python. I think the difference betwen mine and other python solution is "y.val = divs" VS "y.next = y".

    '''
    class Solution(object):
    def addTwoNumbers(self, l1, l2):
    ints = 0
    divs = 0
    x = y = ListNode(0)

        while l1 != None:
            ints,divs = divmod(l1.val + l2.val + ints,10)
            y.val = divs
            y = y.next
            l1 = l1.next
            l2 = l2.next
        return x
    

    '''


Log in to reply
 

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