Linear Search in Python
Linear search function
def linear_search(lst,search):
i = 0
while(i<len(lst)):
if(search == lst[i]):
print("No found at {} position".format(i+1))
break
i+=1
if(i==len(lst)):
print("Not found")
def linear_search(lst,search):
i = 0
while(i<len(lst)):
if(search == lst[i]):
print("No found at {} position".format(i+1))
break
i+=1
if(i==len(lst)):
print("Not found")
Comments
Post a Comment