Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- listnums = []
- for i in range(0,50): #will populate 50 random numbers
- listnums.append(random.randint(0,100)) # will select 50 random numbers between 1-100)
- listnums.sort()
- print(listnums) #the numbers randomly selected will appear below
- print("what integer are you searching for between 1-100?")
- search = int(input()) #requires user to input a number
- found = False
- for i in range (0,len(listnums)): # this checks from the first position in the random number list
- if listnums[i] == search: #if number entered is found in the list
- found = True
- if found == True:
- print("this integer is in the list") #foundl
- else:
- print("this integer is not in the list") #not found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement