Question: Its in python I have added my code from the previous question down below already Continuing on with your LinkedList class implementation, extend the LinkedList
Its in python I have added my code from the previous question down below already

Continuing on with your LinkedList class implementation, extend the LinkedList class by adding the method no_evens(self) which returns True if all values are odd numbers in the linked list, and False otherwise. Submit the entire LinkedList class definition. You can assume that the Node class is available and your code can make use of any of the Node ADT methods: Node (), get_data(), set_data(), get_next() and set_next(). You can also assume that the linked list contains only integer elements. For example: Test Result False linked_list = LinkedList() linked_list.add(2) linked_list.add(4) linked_list.add(1) linked_list.add(3) print(linked_list.no_evens()) True linked_list = LinkedList() linked_list.add(1) linked_list.add(3) linked_list.add(5) print(linked_list.no_evens ( ) ) None 9 counta count += 1 None surrent: texx 7 n.get_next 1 Class LinkedList: 2 def __init__(self): 3 self.__head def add(self, value): > new_node = Node(value) new_node.set_next(self.__head) 1 self.__head = new_node . def size(self): current self.__head 10 11 while 12 count 13 current = current.get_next() 14 return count 15 15 def get_head(self): 16 return self.__head 17 17 def clear(self): 18 self. head 19 19 def is empty(self): 20. 20 if self. head == None: 21 return True 22 else: return false 21 def add_all(self, a_list): for ele in a_list: new_node = Node(ele) new_node.set_next(self.__head) self.__head = new_node def to_list(self): lit = [] current self.__head while current != None: lit.append(current.get_data() current current.get_next() return lit def no_evens(self): #code here 39 def __str 40 "T" 41 n=self. __head 42 while n!=None: 43 text+=str(n.get_data() 44 if n.get_next()!=None: 45 * text+=" --(self): text- 49 return text def __contains__(self, search_value): listed = self.to_list() if search_value in listed: return True return false
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
