#Using A For Loop: ##def linear_search(array, searchterm): ## ## lengthoflist = len(array) ## ## for i in range(lengthoflist): ## ## if array[i] == searchterm: ## return True ## ## return False #Using A While Loop: ## ##def linear_search(array, searchterm): ## ## index = 0 ## ## while index < len(array): ## ## if array[index] == searchterm: ## ## return True ## ## else: ## index = index + 1 ## ## return False def linear_search (array, searchterm, counter): lengthoflist = len(array) if counter == lengthoflist: return False if array[counter] == searchterm: return True return linear_search(array,searchterm, counter + 1) file = open("townlist.txt","r") townlist = [] for line in file: town = line.strip() town = town.lower() townlist.append(town) #print(townlist) #While/For Loop ##found = linear_search(townlist,'nuneaton') ##print(found) #Recursive counter = 0 found = linear_search(townlist, 'nuneaton', counter) print(found)