Question: Python - How do i make a linked list reading numbers from a text file using the node and linked list class? class Node(object): item
Python - How do i make a linked list reading numbers from a text file using the node and linked list class?

class Node(object): item = -1 next = None
def __init__ (self, item, next = None): self.item = item self.next = next
class LinkedList (object):
def get_size (self): return self.size
def add (self, item): new_node = Node (item, self.root); self.root = new_node; self.size += 1;
def add_node (self, next): next.set_next(self.root); self.root = next; self.size += 1;
def find (self, item): this_node = self.root while this_node: if this_node.get_data() == item: return item else: this_node = this_node.get_next() return None def print_list (self): print ("Print List.........."); if self.root is None: return; current = self.root; print (current.to_string()); while current.has_next(): current = current.get_next(); print (current.to_string()); def checkDuplicates(self, node): temp = self.item while(temp!= None): if temp.next = node.next: return temp temp = temp.next return None
if __name__ =='__main__':
File Edit Format 41 2557 4424 1865 2116 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
