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()

At line 8, you are not using the list returned by createRandnums(), and you are passsing h_nums to oss() at line 11 instead of the list. Also I can't see where the list is sorted.

If the list is sorted, you should have a look in the bisect module to implement oss().

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.