Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

select a random element from a list python

import random

# there are 2 ways for this
listofnum = [1, 2, 3, 4, 5]
# 1
print(random.choice(listofnum))

# 2
random.shuffle(listofnum)
print(listofnum)
 
PREVIOUS NEXT
Tagged: #select #random #element #list #python
ADD COMMENT
Topic
Name
5+4 =