title: Is using start and end index method the only way to implement a binary search?
body: <p>Below is my code, when I use <code>test_function</code> it returns fail.  It should return pass.
  What is wrong with making the stop criteria of loop to be length of array == 1 and using length of array as reference for defining middle index.
  All tutorials explain this using start and end index method, is that the only way?</p>
  <pre><code>def binary_search(array, target):
      current_index=(len(array)-1)//2
      while len(array)&gt;1:
          if array[current_index]!=target:
              if target&gt;array[current_index]:
                  array = array[((len(array)-1)//2)+1:]
                  current_index=((len(array)-1)//2)
              else: 
                  array = array[:((len(array)-1)//2)-1]
                  current_index=(len(array)-1)//2
          else: return current_index
      return -1
  
  def test_function(test_case):
      answer = binary_search(test_case[0], test_case[1])
      if answer == test_case[2]:
          print(&quot;Pass!&quot;)
      else:
          print(&quot;Fail!&quot;)
  
  array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  target = 6
  index = 6
  test_case = [array, target, index]
  test_function(test_case) 
  </code></pre>