how to get a random string from a list code example
Example 1: print random string from list python
import random
list = ["Item 1", "Item 2", "Item 3"] # List
item = random.choice(list) # Chooses from list
print(item) # Prints choice
# From stackoverflow
# Tried and tested method
Example 2: sample 1 item from array python
import random
cakes = ['lemon', 'strawberry', 'chocolate']
random.choice(cakes)
# prints 1 randomly selected item from the collection of n items with
# the probability of selection as 1/n
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)