📜  线性搜索python代码示例

📅  最后修改于: 2022-03-11 14:45:37.244000             🧑  作者: Mango

代码示例2
def linear_search(a, key):
    position = 0
    flag = False
    while position < len(a) and not flag:
        if a[position] == key:
            flag = True
        else:
            position = position + 1
    return flag