0
1.6kviews
Write a Python program to perform Linear Search / Linear Search in Python
1 Answer
written 2.5 years ago by |
Explanation:-
Code:-
a=[]
n=int(input("Enter no elements:- "))
flag=index=0
for i in range(n):
print("Enter elements:- ",i)
a.append(int(input()))
print(a)
x=int(input("enter the no to be searched search "))
for i in range(n):
if (x==a[i]):
index=i
flag=1
break
if(flag==0):
print("Element Not Found")
else:
print("Element Found at index",index)
Output:-