input: Write a function to optimize the given Python code using best practices. The original code performs a linear search to find an element in an array. If the element is found, it returns its index; otherwise, it returns -1. Ensure the optimized code is more readable and follows Pythonic conventions.
  
  ### Input:
  
  def linear_search(arr, x):
      for i in range(len(arr)):
          if arr[i] == x:
              return i
      return -1
  
  
  ### Output:
  
  def linear_search(arr, x):
      for index, item in enumerate(arr):
          if item == x:
              return index
      return -1
  
  
  assert linear_search([1, 2, 3, 4, 5], 3) == 2
  assert linear_search([1, 2, 3, 4, 5], 6) == -1
  assert linear_search([], 3) == -1
  assert linear_search([1, 1, 1, 1], 1) == 0
output: def linear_search(arr, x):
      for index, item in enumerate(arr):
          if item == x:
              return index
      return -1