def connect(self, new_sll):
pre = self.head
if sll is SinglyLL():
pre = self.head
for i in range(self.nodenumber):
pre = pre.next
if pre == None :
for i in range(i + new_sll.nodenumber):
aft = pre.next
new = sll.head.data
node = Node(new)
node.next = aft
pre.next = node
self.nodenumber +=1
else :
raise TypeError("error")
I'm trying to connect an existing singly-linked-list (sll
) and another singly-linked-list (new_sll
).
If new_sll
's class type is SinglyLL
, I want to connect new_sll
with the existing sll
and renew the node's number.
If new_sll
's class type is not SinglyLL
, I want to show a type error
I can't solve this matter... how can I fix my code?