Python: NameError: global name 'sortList' is not defined (During Recursion) -
in line (l1 = sortlist(head)) recursion, nameerror: global name 'sortlist' not defined. point out did wrong?
class solution: # @param head, listnode # @return listnode def sortlist(self, head): if head == none or head.next == none: homecoming head slow = head fast = head while fast != none , fast.next != none: slow = slow.next fast = fast.next.next fast = slow slow = slow.next fast.next = none l1 = sortlist(head) l2 = sortlist(slow) l = mergetwolists(l1, l2) homecoming l
sortlist method of solution, , doesn't exist independently. use:
self.sortlist(head) and work.
python recursion
No comments:
Post a Comment