# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
import numpy as np
class Solution:
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
l=l1
m = len(l)-1
for i in l2:
m = m + 1
l = np.insert(l,m,i)
l = np.sort(l)
return l
在做LeeCode简单题目21合并两个有序链表……在pycharm上跑没有问题,在网页上报错:
TypeError: object of type 'ListNode' has no len()
m = len(l)-1
Line 10 in mergeTwoLists (Solution.py)
ret = Solution().mergeTwoLists(param_1, param_2)
Line 42 in _driver (Solution.py)
_driver()
Line 53 in <module> (Solution.py)
疯了,感觉自己python学了个寂寞!大神求救!