input: def linear_search(arr, x):
      """ Optimized version of the linear search algorithm using enumerate
      to combine both index and item retrieval. It returns the index of the
      first appearance of x or -1 if it is not found.
  
      >>> linear_search([1, 2, 3, 4], 3)
      2
      >>> linear_search([1, 2, 3, 4], 5)
      -1
      """
      for index, item in enumerate(arr):
          if item == x:
              return index
      return -1
output:     for index, item in enumerate(arr):
          if item == x:
              return index
      return -1