Function to insert node in a linked list
def insert ( root , item ) : NEW_LINE INDENT temp = Node ( 0 ) NEW_LINE temp . data = item NEW_LINE temp . next = None NEW_LINE if ( root == None ) : NEW_LINE INDENT root = temp NEW_LINE DEDENT else : NEW_LINE INDENT ptr = root NEW_LINE while ( ptr . next != None ) : NEW_LINE INDENT ptr = ptr . next NEW_LINE DEDENT ptr . next = temp NEW_LINE DEDENT return root NEW_LINE DEDENT