python - adding is_empty to hashtable -


i'm trying add is_empty(self) method. return true if hash table maps no keys values, else false. have @ moment i'm unsure how approach is_empty function using self.

class myhashtable:      def __init__(self, capacity):          self.capacity = capacity          self.slots = [none] * self.capacity      def __str__(self):          return str(self.slots )      def is_empty(self)          pass 

as self.slots list, , goal test elements none. suggest:

def is_empty(self)     return self.slots.count(none) == len(self.slots) 

see how check if items in list none? answer there , others.


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -