class Item(object): def __init__(self, key, value): self.key = key self.value = value class HashTable(object): def __init__(self, size=10): self.size = size self.array = [[] for _ in range(self.size)] def _hash_function(self, key): return key % self.size def set(self, key, value): hash_index = self._hash_function(key) for node in self.array[hash_index]: if node.key == key: node.value = value return self.array[hash_index].append(Item(key, value)) def get(self, key): hash_index = self._hash_function(key) for node in self.array[hash_index]: if node.key == key: return