issue with self made random number generator in python. (using time.time())
Question: I am well aware that python has a built in random library, so please do not
include any reference to it in this. I am taking a do-it-yourself approach
using `time.time()`. I made a simple random number generator as is shown
below:

    
    
    def random(x, y):
        import time
        choices = [i for i in range(x, y)]
        t = time.time()
        num = int(str(t-int(t))[2:])%100
        xnum = [i for i in range(num, choices[-1])]
        ynum = [choices[i] for i in xnum]
        znum = ynum[choices[num-1]]
        ret = choices[znum]
        return ret
    

This works pretty well for anything like `random(1, 200)`; however, it has
some issues. For example, if i were to do `random(10, 200)`, it would give an
index error. How could I improve/change this to make it handle any two
numbers?


Answer: You would need to have a function, say `randombits()` which generates a random
integer in some range (i.e. 256 or 2^32). Then your `random()` function needs
to first take the difference of `x` and `y`, i.e. the number of possible
outputs of `random(x, y)`. Then it needs to calculate how many times
`randombits()` has to be called in order to have enough entropy. Then it needs
to combine the values of the multiple calls of `randombits()` into one long
integer. One way to do this is to place output of `randombits()` into a
separate digit of the long random integer, i.e. if the outputs of the calls
are `8, 9, 1` then the long random integer will be 891.

Then it needs to scale down the long random integer to the number of possible
outputs (the difference between x and y). One way to do this which
`random.random()` uses is to keep getting a long random integer until it is
within the range. Then it needs to add the long random integer to `x` and that
should be returned.

Code:

    
    
    RANDOMBITS_RANGE = 256
    
    def randombits():
    
        return 4 # Replace this code with something that generates real random numbers
    
    def random(x,y):
        num_range = y-x
        num_of_calls = num_range//RANDOMBITS_RANGE
        random_integer = num_range + 1 #So that the first time the while loop block will execute
        while random_integer >= num_range: #Keeps looping until random_integer < num_range
            random_integer = sum(randombits()*RANDOMBITS_RANGE**x for x in range(num_of_calls))
        return random_integer
    

