title: Binary search Python Why do we use mid + 1 or mid - 1
body: <p>I am learning binary search and the sample code uses" <code>low = mid +1 and high = mid -1</code>" but I don't understand why we do not use "<code>low = mid and high = mid</code> " instead? </p>
  
  <pre><code>def binarysearch(sequence, value):
      lo, hi = 0, len(sequence) - 1
      while lo &lt;= hi:
          mid = (lo + hi) // 2
          if sequence[mid] &lt; value:
              lo = mid + 1
          elif value &lt; sequence[mid]:
              hi = mid - 1
          else:
              return mid
      return None
  
  my_list = [1, 3, 5, 7, 9]
  binarysearch(my_list, 3)
  </code></pre>