Generate random numbers in range from INPUT (python)
<p>This is a question close to some others I have found but they don't help me so I'm asking specifically for me and my purpose this time. </p>

<p>I'm coding for a bot which is supposed to ask the user for max and min in a range, then generating ten random numbers within that range. When validating I'm told both <code>random</code> and <code>i</code>are unused variables. I don't really get why. I believed <code>random.radint</code>was supposed to be a built in function and as far as <code>i</code> is concerned I really don't know what to believe. This is what I've got so far. </p>

<pre><code>def RandomNumbers():
    """
    Asking the user for a min and max, then printing ten random numbers between min and max.
    """
    print("Give me two numbers, a min and a max")
    a = input("Select min. ")
    b = input("Select max. ")


    for i in range(10):
        number = random.randint(a, b)
    print(str(number)+ str(","), end="")
</code></pre>

<p>I'll be very happy for every piece of advice I can get to complete my task. Thank you in advance!</p>

<p>No. <code>random.randint</code> is not a builtin function. You'll have to <em>import</em> the <code>random</code> module to use the function.</p>

<p>On another note, <code>i</code> was evidently not used in the loop, so you'll conventionally use the underscore <code>_</code> in place of <code>i</code></p>

<pre><code>import random


numbers = []
for _ in range(10):
    numbers.append(random.randint(a, b))
</code></pre>

<p>You'll also notice I have used a list to store all the values from each iteration. In that way, you don't throw away the values from previous iterations.</p>

<p>In case you're not already familiar with lists, you can check out the docs: </p>

<p><a href="https://docs.python.org/2/tutorial/datastructures.html#data-structures" rel="nofollow">Data structures</a></p>

<p><em>Lists:</em></p>

<blockquote>
  <p>The items of a list are arbitrary Python objects. Lists are formed by
  placing a comma-separated list of expressions in square brackets</p>
</blockquote>

<hr>

<p>On a final note, to print the items from your list, you can use the <a href="https://docs.python.org/2/library/stdtypes.html#str.join" rel="nofollow"><code>str.join</code></a> method, but not after the items in your list have been converted from integers to strings:</p>

<pre><code>output = ', '.join([str(num) for num in numbers])
print(output)
</code></pre>

python