EdDoc: home/built-in_modules/random/random.choice
A function available after importing the built-in random module.
Returns a random value from a container data-type.
The identifier name for a container variable.
a randomly chosen value from the container data-type passed to it.
It randomly selects a character from a string:
>>> random.choice('abcde') 'd'
It randomly selects a value from a tuple or a list:
>>> my_tuple = (5, 4, 3, 2, 1) >>> random.choice(my_tuple) 4
[Note choice() cannot be used with dictionaries.]