Logo

Programming-Idioms

History of Idiom 11 > diff from v84 to v85

Edit summary for version 85 by gnrfan:
[Python] duplicate - can be deleted

Version 84

2019-12-26, 16:42:55

Version 85

2019-12-26, 16:44:32

Idiom #11 Pick a random element from a list

List x must be non-empty.

Illustration

Idiom #11 Pick a random element from a list

List x must be non-empty.

Illustration
Extra Keywords
choose
Extra Keywords
choose
Imports
from random import choice
Imports
from random import choice
Code
random.choice(_x)
Code
choice(_x)