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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -