python 无序表查找
def sequential_search(lis, key): for i in range(len(lis)): if(lis[i] == key): return i else: return False LIST = [1, 5, 8, 123, 22, 54, 7, 99, 300, 222] result = sequential_search(LIST, 5) print(result)
def sequential_search(lis, key): for i in range(len(lis)): if(lis[i] == key): return i else: return False LIST = [1, 5, 8, 123, 22, 54, 7, 99, 300, 222] result = sequential_search(LIST, 5) print(result)