English

Write a program to input n numbers and to search any number from the list.

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?
Chapter 1: Review of Phython - EXERCISE [Page 27]

APPEARS IN

CBSE Computer Science with Python [English] Class 12
Chapter 1 Review of Phython
EXERCISE | Q 28. | Page 27
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×