Advertisements
Advertisements
Question
Write a program to input n numbers and to search any number from the list.
Code Writing
Advertisements
Solution
Input the list and use the membership operator in to search the number.
n = int(input("Enter number of elements: "))
numbers = []
for i in range(n):
number = int(input("Enter a number: "))
numbers.append(number)
search_number = int(input("Enter number to search: "))
if search_number in numbers:
print("Number found in the list")
else:
print("Number not found in the list")shaalaa.com
Is there an error in this question or solution?
