Write a program to generate 100 random numbers between the range 1 and 1000 and search for a number through user input.
import random
numbers=[]
for i in range(0,100):
numbers.append(random.randint(1,1000))
userValue =int(input("Enter the number [1-1000]: "))
index=-1
for i in range(0,100):
if numbers[i]==userValue:
index=i
if index!=-1:
print("The number exists in array")
else:
print("The number does NOT exist in array")
Comments
Leave a comment