scarygarey

linear_sorted

Jan 14th, 2020
72
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. listnums.sort()
  6. print(listnums) #the numbers randomly selected will appear below
  7.  
  8. print("what integer are you searching for between 1-100?")
  9. search = int(input()) #requires user to input a number
  10.  
  11. found = False
  12.  
  13. for i in range (0,len(listnums)): # this checks from the first position in the random number list
  14. if listnums[i] == search: #if number entered is found in the list
  15. found = True
  16.  
  17. if found == True:
  18. print("this integer is in the list") #foundl
  19. else:
  20. print("this integer is not in the list") #not found
RAW Paste Data