Header Ads Widget

Write a python program for linear search.

What is linear searching:-

Linear searching is a searching algorithm in which we search the elements linearly .  we compare the element with all the elements and if elements is found in the list then break the loop and print element is present in the list.  


print("Enter the list of the number")
num=int(input("Enter the number for searching"))
for i in mylist:
if i==num:
print("Value is in the list")
print("Value is not in the list")


Enter the list of the number
12 23 43 54 67 8
Enter the number for searching 12
Value is in the list

Recommended Post:-