मराठी

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×