LINEAR SEARCH IN PYTHON

Linear Search Algorithm

Program :

list_1 = [67,12,34,65,87,90,54,78,23]
search_value = int(input('Enter the value to search : '))
i = 0
while i<len(list_1) :
if list_1[i] == search_value :
print('The element is present in the list at the',i+1,'position')
break
i += 1
else :
print('The element is not present in the list')

Output :

Enter the value to search : 72
The element is not present in the list
Enter the value to search : 90
The element is present in the list at the 6 position

Comments

Popular posts from this blog

MOTION DETECTION AND TRACKING USING OPENCV AND PYTHON

COLOR DETECTION USING OPENCV AND PYTHON

DETECTING ACCURACY LEVEL OF THE KNOWN AND TEST FACES USING PYTHON