input: Write a function to optimize the given linear search algorithm using best practices. The function should take an array and a target value as input and return the index of the target value in the array if it exists, otherwise return -1. If the array is empty, the function should return -1 as well.
      
  assert linear_search([1, 2, 3, 4, 5], 3)==2
  assert linear_search([1, 2, 3, 4, 5], 6)==-1
  assert linear_search([1, 2, 3, 4, 5], 1)==0
  assert linear_search([], 1)==-1
output: def linear_search(arr, target):
      for i in range(len(arr)):
          if arr[i] == target:
              return i
      return -1