Advertisement
scarygarey

linear_unsorted

Jan 14th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import random
  2. listnums = []
  3. for i in range(0,50): #will populate 50 random numbers
  4. listnums.append(random.randint(0,100)) # will select 50 random numbers between 1-100)
  5. print(listnums) #the numbers randomly selected will appear below
  6.  
  7. print("what integer are you searching for between 1-100?")
  8. search = int(input()) #requires user to input a number
  9.  
  10. found = False
  11.  
  12. for i in range (0,len(listnums)): # this checks from the first position in the random number list
  13. if listnums[i] == search: #if number entered is found in the list
  14. found = True
  15.  
  16. if found == True:
  17. print("this integer is in the list") #foundl
  18. else:
  19. print("this integer is not in the list") #not found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement