random.pick python code example
Example 1: print random string from list python
import random
list = ["Item 1", "Item 2", "Item 3"]
item = random.choice(list)
print(item)
Example 2: random picker in python
import random
x_dict = {30:60, 20:40,10:20}
key = random.choice(list(x_dict))
print (key)
print (x_dict[key])
print (key,"-", x_dict[key])
Example 3: Select an element of a list by random
import random
rand_index = random.randrange(len(list))
random_num = list[rand_index]
random_num = random.choice(list)