Insert a Node at the Tail of a Linked List

  • + 0 comments

    Python

    def insertNodeAtTail(head, data):
        node = SinglyLinkedListNode(data)
        if head is not None:
            current = head
            while current.next is not None:
                current = current.next
            current.next = node
        else:
            head = node
        
        return head