W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
def linearSearch(arr, targetVal): for i in range(len(arr)): if arr[i] == targetVal: return i return -1 mylist = [3, 7, 2, 9, 5, 1, 8, 4, 6] x = 4 result = linearSearch(mylist, x) if result != -1: print("Found at index", result) else: print("Not found")