+ 2
What term can I use to get a random number or letter between a range in python?
I just need to get a random number or letter for example if I had a list = [ "p", "q", "r", "t"] and I wanted to get a reandom letter from list what do I do?
1 Antwort
+ 9
The easiest is probably to use the random.sample() method:
from random import sample
my_list = ["p", "q", "r", "t"]
print(sample(my_list, 1))