Computer Science, asked by avsrikanth015, 6 months ago

WAP in python to accept integer array and search a particular value in the array. If it exists, then the function should display "exists”, otherwise should display “Does not exist”

Answers

Answered by PRahul
3

Answer:

numberList = []

n = int(input("Enter the list size : "))

print("\n")

for i in range(0, n):

   print("Enter number at location", i, ":")

   item = int(input())

   numberList.append(item)     #append method help to store no in array

gn=int(input("ENTER A NO YOU WANT TO SEARCH"))     #gn -stores the no                      #  which is to be searched

for i in range(0, n):        #this loop search the no in  the array

   if gn== numberList[i]:   #if the no is present the value of p will be 1 else 0

     p=1

     break

   else:

       p=0

if p==1:

    print("exist")  

else:

   print("does not exist")  

Similar questions