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