Why I got this error


  • -1
    N
    class Solution:
        # @param {ListNode} head
        # @return {ListNode}
        def reverseList(self, head):
            while True:
                if head.next == None:
                    break
                
                temp = head.next
                head = temp
                head.next = head
                reverseList(temp)
    

    I got this error

    Runtime Error Message:
    Line 12: AttributeError: 'NoneType' object has no attribute 'next'
    Last executed input:
    []

  • 0
    N

    The input is "None" and "head.next" will hit this error.


Log in to reply
 

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