Write a program for a linear search.
- def linersearch(search,list):flag=0for item in list:if search==item:flag=1breakif flag==1:print("value exist.")else:print("value does not exist.")elements=[]num_of_elmenets=int(input("how many elment you want to Enter: "))for i in range(num_of_elmenets):elm=int(input("Enter element "))elements.append(elm)ser=int(input("enter the value to search: "))linersearch(ser,elements)
Output:-
0 Comments