Optimize the following python code using best practices
def linear_search(arr, x):
    for i in range(len(arr)):
        if arr[i] == x:
            return i
    return -1
def linear_search(arr, x):
    for index, item in enumerate(arr):
        if item == x:
            return index
    return -1