def
Lsearch(ar,item):
i=0
while i<len(ar) and ar[i]!=item:
i=i+1
if i<len(ar):
return i
else:
return Flase
N=int(input("Enter
total numbers of the list"))
print("\nEnter
elements for the list\n")
ar=[0]*N #initialize list of size N with zero
for
i in range(N):
ar[i]=int(input("Element"+str(i)+":"))
item=int(input("Enter
element to be searched"))
index=Lsearch(ar,item)
if
index:
print("Element found at",
index+1)
else:
print("Element not found")
Comments
Post a Comment