How do I randomly select an item from a list using Python?
Question: Assume I have the following list:

    
    
    foo = ['a', 'b', 'c', 'd', 'e']
    

What is the simplest way to retrieve an item at random from this list?


Answer: Use
[`random.choice`](https://docs.python.org/2/library/random.html#random.choice):

    
    
    import random
    
    foo = ['a', 'b', 'c', 'd', 'e']
    print(random.choice(foo))
    

