title: How can I resize hash table in python?
body: <p>I am trying to implement hash table in python. I am struggling resizing hash table in case there is duplicate address or hash table is too small.</p>
  
  <p>This is my constructor,</p>
  
  <pre><code>def __init__(self):
      self.table_size = [11, 23, 47, 97, 197, 397, 797, 1597, 3203, 6421,
                        12853,
                    25717, 51437, 102877, 205759, 411527, 823117, 1646237,
                    3292489, 6584983, 13169977, 26339969, 52679969,
                    105359939, 210719881, 421439783, 842879579, 1685759167]
      self.table_size_index = 0
      self.counter = 0
      self.size = self.table_size[self.table_size_index]
      self.slot = [None] * self.size
      self.data = [None] * self.size
  </code></pre>
  
  <p><code>table_size</code> contains enough prime numbers to create big hash table.
  <code>table_size_index</code> indicates what table size I am using.</p>
  
  <p>My <code>put</code> function is,</p>
  
  <pre><code> def put(self, key, val):
          hash_value  = self.hash_function(key, len(self.slot))
          if self.slot[hash_value] == None:
              self.slot[hash_value] = key
              self.data[hash_value] = val
              #self.counter += 1
          else:
  
              if self.table_size_index &lt; len(self.table_size) -1 :
                  self.table_size_index += 1
                  new_slot = [None] * self.table_size[self.table_size_index]
                  new_data = [None] * self.table_size[self.table_size_index]
  
                  # copying old hash table to new hash table
                  for i in self.slot:
                      new_hash_value = self.hash_function(i, len(new_slot))
                      new_slot[new_hash_value] = i
                      temp = self.slot.index(i)
                      new_data[new_hash_value] = self.data[temp]
                  self.slot = new_slot
                  self.data = new_data
  </code></pre>
  
  <p>It always prints out <code>11</code> length of <code>slot</code> and <code>data</code>. If the key already exist, it does not increase its size. How can I fix this one?
  Thanks in advance!</p>