Sequential Search in list Program in Python

Python
Python


Code:

abc=[1,2,3,4,5]
n=len(abc)
loc=-1
item=int(input("enter item "))
for i in range(n):
  if(item == abc[i]):
    loc=i
    print("data found at Index ",loc)
  elif(loc==-1):
    print("item not found")



Output:

enter item 5
item not found
item not found
item not found
item not found
data found at Index  4
>>> 


Tags: 
linear search,sequential search,python,linear search in python,binary search,sequential search in python,search,linear search program in python,list program in python in hindi,linear search program in python in hindi,linear search algorithm,list program in python for practice,linear search in c,linear search python,list in python,list in python programming,list in python in hindi,program

Post a Comment

Previous Post Next Post