+ 3
How can I select a random item of a list in python?
5 Answers
+ 6
import random
print(random.choice(List_name))
+ 4
Import random
Numbers=list(range(1,100)
Num=random.choice(numbers)
A random number will be chosen.
+ 3
l=[1,2,3,4]
X=l[random.randint(0,len(l)-1)]
+ 2
1: import random
2: list= ['r', 's', 't', 'l', 'k'] print(random.choice(list))
could slice also
+ 1
import random
list = [1,2,3,4,5,6,7,8,9]
x = random.sample(list,1)
print(x)