input: Write a function to implement a binary search in a sorted list and return the index of the target value if found, otherwise return -1. If the list is empty, return -1.
  def binary_search(nums, val):
      low = 0
      high = len(nums) - 1
      
      while low <= high:
          mid = (low + high) // 2
          if nums[mid] == val:
              return mid
          elif nums[mid] > val:
              high = mid - 1
          else:
              low = mid + 1
      return -1
  
  assert binary_search([], 3)==-1
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 8)==5
  assert binary_search([1, 2, 3, 4, 5], 2)==1
  assert binary_search([11, 22, 33, 44, 55], 66)==-1
  assert binary_search([10, 20, 30, 40, 50], 15)==-1
output: def binary_search(nums, val):
      low = 0
      high = len(nums) - 1
      
      while low <= high:
          mid = (low + high) // 2
          if nums[mid] == val:
              return mid
          elif nums[mid] > val:
              high = mid - 1
          else:
              low = mid + 1
      return -1