Linear search

Liner search full python program

Hey internet mates here we are going to make a python program to search for an element in the given list using the linear search method.

Program code:-
li=[]
enter=int(input("No. of letter you wants to enter:-"))
print("Enter Numbers:")
for x in range(enter):
    r=int(input(":-"))
    li.append(r)
print("Inputted list:",li)
key=int(input("Enter Key:"))
if key in li:
    for x in range(len(li)):
        if li[x]==key:
            print("ITEM FOUND AT POSITION:-",x+1)
        else:
            pass
else:
    print("Item do not exist:")

1 thought on “Linear search”

Leave a Comment

Your email address will not be published. Required fields are marked *