📜  python代码示例中的线性搜索

📅  最后修改于: 2022-03-11 14:45:47.216000             🧑  作者: 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