Question: question : complete an UnorderedList class using the node class below. append: adds data to the list __len__ : returns the length of the list
question : complete an UnorderedList class using the node class below.
append: adds data to the list
__len__ : returns the length of the list
__getitem__ : returns the data of the index given
__setitem__ : changes (or sets) the data at the index given
__str__ : returns the list as a string

class Node: def init-data): _init-(self, self.data - init data self, next = None def get_data(self): def get_next(self): def set_data(self, new_data): def set_next (self, new next): return self.data return self.next self.data = new data self.next new next class UnorderedList: def init(self): self.head -None def is_empty(self): return sel f . head : None def append (self, item): # Code Here def-len-(self): # Code Here def getitem (self,key): def setitem (self,key, item): def-str-(self): # Code Here # Code Here # Code Here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
