हिंदी

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

Advertisements
Advertisements

प्रश्न

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

कोड लेखन
Advertisements

उत्तर

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
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Review of Phython - EXERCISE [पृष्ठ २७]

APPEARS IN

सीबीएसई Computer Science with Python [English] Class 12
अध्याय 1 Review of Phython
EXERCISE | Q 28. | पृष्ठ २७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×