Question: Hey I need help with this question it is in python: Consider the Node class definition in the answer box below, add a method named

Hey I need help with this question it is in python:

Hey I need help with this question it is in python: Consider

Consider the Node class definition in the answer box below, add a method named get_list(self) to extend its functionality. The get_list() method returns a Python list of all the values of the nodes in the chain starting from the current node. For example, for the chain of nodes: 40 -> 30 -> 10 -> 5, and the get_list() method is invoked at the first node, then the method returns [40, 30, 10,5] as a Python list. Note: Submit the entire class definition in the answer box below. For example: Test Result ['abc', 'def'] ['def'] nodel = Node('abc') node2 = Node('def') nodel.set_next(node2) print(nodel.get_list) print(node2.get_list() nodel = Node (5) [5] node2 = Node(10, node1) [10, 5] node3 = Node (30, node2) [30, 10, 5] node4 = Node (40, node3) [40, 30, 10, 5] print(nodel.get_list) print(node2.get_list) print(node3.get_list) print(node4.get_list() get_next(self) Answer: (penalty regime: 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50 %) Reset answer 1 class Node: 2 def __init__(self, data, next=None): self. _data data self. next = next def get- _data(self): return self data def return self. next 9 def set_data(self, new_data): data ' def set_next(self, new_next): new_data celt self next new_next . 13 def _str(self) return str(self.__data) 15 16 new_node = Node(value, self. __next ) 17 self. _next = new_node 18 def remove_after(self): 19 self. next self._next.get_next() self def add add_after(self, value) 29

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!