input: Write a function to implement binary search in a sorted list of numbers. The function should return the index of the target value if it exists in the list, otherwise return -1. If the input list is empty, return -1.
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 8)==5
  assert binary_search([], 5)==-1
  assert binary_search([1, 2, 3, 4, 5], 3)==2
  assert binary_search([10, 20, 30, 40, 50], 60)==-1
  assert binary_search([1, 3, 5, 7, 9], 9)==4
output: def binary_search(arr, target):
      if not arr:
          return -1
      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