input: Write a function to optimize the given linear search code using best practices. The function should return the index of the element if found in the array, otherwise return -1.
  assert linear_search([1, 2, 3, 4, 5], 3) == 2
  assert linear_search([10, 20, 30, 40, 50], 50) == 4
  assert linear_search([1, 3, 5, 7, 9], 4) == -1
  assert linear_search([], 1) == -1
output: def linear_search(arr, target):
      for i, value in enumerate(arr):
          if value == target:
              return i
      return -1