input: Write a function to implement a binary search algorithm. The function should take a sorted list of numbers and a target value as input. If the target value is found in the list, it should return the index of the target value. If the target value is not found, it should return -1.
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 8)==5
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 10)==-1
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 3)==0
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 9)==6
  assert binary_search([], 8)==-1
output: def binary_search(arr, target):
      left, right = 0, len(arr) - 1
      while left <= right:
          mid = (left + right) // 2
          if arr[mid] == target:
              return mid
          elif arr[mid] < target:
              left = mid + 1
          else:
              right = mid - 1
      return -1