TypeError: randint() got an unexpected keyword argument 'low'
<pre><code>names = ['Bob', 'Jessica', 'Mary', 'John', 'Mel']
import random
random.seed(500)
random_names = [names[random.randint(low = 0, high = len(names))] for i in range(1000)]
</code></pre>

<p>Objective is to make a random list of 1,000 names using the five above. But the above code throws back the following error : </p>

<pre><code>Traceback (most recent call last):
  File "&lt;pyshell#88&gt;", line 1, in &lt;module&gt;
    random_names = [names[random.randint(low = 0, high = len(names))] for i in range(1000)]
TypeError: randint() got an unexpected keyword argument 'low'
</code></pre>

<p>Remove <code>low</code> and <code>high</code> and your code will work fine. i.e. <code>random.randint(0, len(names)-1)</code></p>

<p>However, more efficient way to do it is using <a href="https://docs.python.org/2/library/random.html#random.choice" rel="nofollow"><code>random.choice()</code></a></p>

<pre><code>&gt;&gt;&gt; [random.choice(names) for i in range(10)]
['Mel', 'Mary', 'Mary', 'John', 'Bob', 'Mel', 'John', 'Jessica', 'Jessica', 'John']
</code></pre>

python python-2.7 random