Online Python Compiler

class Node: def __init__(self,data): self.data = data self.next = None class list_creation: def __init__(self): self.head = Node(None) self.tail = Node(None) self.head.next = self.tail self.tail.next = self.head def add_data(self,my_data): new_node = Node(my_data) if self.head.data is None: self.head = new_node self.tail = new_node new_node.next = self.head else: self.tail.next = new_node self.tail = new_node self.tail.next = self.head def search_value(self,elem_to_search): curr = self.head; i = 1; flag_val = False; if(self.head == None): print("The list is empty"); else: while(True): if(curr.data == elem_to_search): flag_val = True; break; curr = curr.next; i = i + 1; if(curr == self.head): break; if(flag_val): print("The element is present in list at position : " + str(i)); else: print("The element is not present in list"); def print_it(self): curr = self.head if self.head is None: print("The list is empty"); return; else: print(curr.data) while(curr.next != self.head): curr = curr.next print(curr.data) print("\n") class circular_linked_list: my_cl = list_creation() print("Nodes are being added to the list") my_cl.add_data(21) my_cl.add_data(54) my_cl.add_data(78) my_cl.add_data(99) my_cl.add_data(27) print("The list is :") my_cl.print_it() print("Value 99 is being searched") my_cl.search_value(99) print("Value 0 is being searched") my_cl.search_value(0)