Write a program to perform 'Linear Search' on a list of integers given below, to search for an element input by the user, if it is found display the message "Search successful" otherwise display "Search unsuccessful
51, 7, 29, 11, 15, 120, 30, 45, 89, 79
Answers
Answered by
1
def linear_search(item):
numbers = [51, 7, 29, 11, 15, 120, 30, 45, 89, 79]
for number in numbers:
if number == item:
return "Search successful"
return "Search unsuccessful"
if __name__ == "__main__":
item = int(input("item: "))
print(linear_search(item))
Similar questions
Hindi,
2 months ago
CBSE BOARD XII,
2 months ago
English,
2 months ago
Computer Science,
5 months ago
History,
10 months ago
CBSE BOARD X,
10 months ago