inserting item after another item linked list python

Solutions on MaxInterview for inserting item after another item linked list python by the best coders in the world

showing results for - "inserting item after another item linked list python"
Bria
25 Aug 2016
1    def insert_after_item(self, x, data):
2
3        n = self.start_node
4        print(n.ref)
5        while n is not None:
6            if n.item == x:
7                break
8            n = n.ref
9        if n is None:
10            print("item not in the list")
11        else:
12            new_node = Node(data)
13            new_node.ref = n.ref
14            n.ref = new_node
15