How to remove a random element from a list and add it to another list in python
<p><code>list = ['john','james','michael','david','william']</code></p>

<p><code>winner = []</code></p>

<p>How can I remove a random item from <code>list</code> and add it to <code>winner</code>?</p>

<p>This selects a random item from a list of names <code>names</code> and adds it to another list <code>winner</code>. The chosen winner is then removed from the <code>names</code>.</p>

<pre><code>import random
winner = []
names = ['john','james','michael','david','william']
winnerindex = random.randint(0,len(names)-1)
winner.append(names[winnerindex])
del names[winnerindex]
print winner, names
</code></pre>

python list random-access