input: Write a function to perform a binary search on a sorted list of items and return the index of the item if it is found, otherwise return -1. The function should take a list of numbers and a value to search for as its parameters.
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 8)==5
  assert binary_search([3, 4, 5, 6, 7, 8, 9], 2)==-1
  assert binary_search([], 8)==-1
  assert binary_search([5], 5)==0
  assert binary_search([1, 2, 3, 4, 5, 6, 7, 8, 9], 6)==5
output: def binary_search(arr, x):
      low = 0
      high = len(arr) - 1
      while low <= high:
          mid = (high + low) // 2
          if arr[mid] < x:
              low = mid + 1
          elif arr[mid] > x:
              high = mid - 1
          else:
              return mid
      return -1