Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Last active August 10, 2020 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexnikol/1c644c3b8ec1a67dea2d331406e1570c to your computer and use it in GitHub Desktop.
Save alexnikol/1c644c3b8ec1a67dea2d331406e1570c to your computer and use it in GitHub Desktop.
Insert a Node at the Tail of a Linked List. Realization
from linked_list import SinglyLinkedListNode
def insertNodeAtTail(head, data):
if head is None:
return SinglyLinkedListNode(data)
else:
current_node = head
while current_node.next is not None:
current_node = current_node.next
current_node.next = SinglyLinkedListNode(data)
return head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment