Its a very simple program of adding a node at the end of a link list. I dont know what mistake I am doing. has it something to do with the exoected output of hackerRank or there's a mistake in my code. I m trying to implement the Python2
class Node(object):
def __init__(self, data=None, next_node=None):
self.data = data
self.next = next_node
def Insert(head, data):
if (head.head == None):
head.head = Node(data)
else:
current = head.head
while (current.next != None) and (current.data == data):
current = current.next
current.next = Node(data)
Heres a link to the question. https://www.hackerrank.com/challenges/insert-a-node-at-the-tail-of-a-linked-list