This document describes a linear search algorithm to find a number in a list. It defines a list of numbers, prompts the user to input a number to search for, iterates through the list using a for loop, checks if each element is equal to the search item, and prints either the index where the item was found or a message that it was not found in the list.
This document describes a linear search algorithm to find a number in a list. It defines a list of numbers, prompts the user to input a number to search for, iterates through the list using a for loop, checks if each element is equal to the search item, and prints either the index where the item was found or a message that it was not found in the list.
This document describes a linear search algorithm to find a number in a list. It defines a list of numbers, prompts the user to input a number to search for, iterates through the list using a for loop, checks if each element is equal to the search item, and prints either the index where the item was found or a message that it was not found in the list.
print ('List has the items: ',nlist) searchItem = int (input ('Enter the number you want to find: ')) found = False for i in range (len(nlist)) : if nlist[i] == searchItem: found = True print(searchItem, ' was found in the list at index', i) break if found == False: print(searchItem, ' was not found in the list!')