#Chapter 45 Linear search #Linear search of a list to find itemSought #returns index of item if found, -1 otherwise def linearSearch(alist,itemSought): for i in range(len(alist)): if alist[i] == itemSought: return i return -1 #main program a=[1,6,4,8,9,3,4,12,71,34,15] key = int(input("Enter key: ")) i = linearSearch(a,key) if i == -1: print("Key not in list") else: print (a[i], " is at index",i)