input: Write a function to optimize the given Python code using best practices. The given code performs a linear search on an array to find a specified element and returns its index if found, otherwise returns -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
output: def linear_search(arr, target):
      for i, value in enumerate(arr):
          if value == target:
              return i
      return -1