Help with passing the arguments.
This program is supposed to ask for how many numbers do you want. I would stick with ten. Then how many numbers in a randrange (upper limit) Please choose 100
After a list is generated it is supposed to sort the numbers and look for a certain number. The print statement is not necessary I was just doing that for testing. It keeps crashing on the OSS function. So basically I am having trouble with passing arguments.
Any suggestions.
from random import randrange
import time
def main():
print "Choose how many numbers you want"
print "Numbers must be less than upper limit"
h_nums = input("How many numbers do you want: ")
r_nums = input("Please input upper range limit: ")
createRandnums(h_nums,r_nums)
f_num = input("What number are you looking for. Stay within range: ")
start = time.clock()
oss(h_nums, f_num)
elapsed = (time.clock() - start)
print elapsed
def createRandnums(num1,num2):
alist = []
for i in range(num1):
total = randrange(1,num2,1)
alist.append(total)
print alist
return alist
def oss(alist, item):
pos = 0
found = False
stop = False
while pos < len(alist) and not found and not stop:
if alist[pos] == item:
found = True
else:
if alist[pos] > item:
stop = True
else:
pos = pos+1
return found
main()