97
votes

The first examples that I googled didn't work. This should be trivial, right?

2
This was in my first hit: docs.python.org/library/random.html#module-random -- random.choice(seq)¶ Return a random element from the non-empty sequence seq.Daniel Sloof
Many times looking in the library can be more helpful. Getting the documentation for the random module would have worked. It does take some time to know where to look, but for anything involving "random" check the random module first.Kathy Van Stone

2 Answers

206
votes
import random
random.choice (mylist)
51
votes
import random
random.choice([1, 2, 3])