Linear search, also known as sequential search, is the simplest search method. Its basic idea is to start from the first record and compare the keywords of the records one by one until the specific value you are looking for is found.
def search(arr,n,x):
for i in range(0,n):
if (arr[i] == x):
return i
return -1
arr = ["b","c","d","e","a",]
x = "d"
n = len(arr)
result = search(arr,n,x)
if(result == -1):
print("元素不再数组中")
else:
print("元素在数组中的索引为{}".format(result))