Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

select randomly from list in loop

>>> num = [1, 2, 3, 4, 5, 6]
>>> while len(num) > 0:
...   n = random.choice(num)
...   print("selected : ", n)
...   num.remove(n)
...   print("num is now: ", num)
... 
selected :  3
num is now:  [1, 2, 4, 5, 6]
selected :  5
num is now:  [1, 2, 4, 6]
selected :  4
num is now:  [1, 2, 6]
selected :  1
num is now:  [2, 6]
selected :  6
num is now:  [2]
selected :  2
num is now:  []
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #select #randomly #list #loop
ADD COMMENT
Topic
Name
2+7 =