python pick one item from list 1

python pick one item from list

import random
my_list = ['one', 'two', 'three']
pick = random.choice(my_list)
print(pick)

Here is what the above code is Doing:
1. We import the random module.
2. We create a list of strings.
3. We use the random.choice() function to pick a random item from the list.
4. We print the random item.

Similar Posts