Title: Select Random Item From A Lists Slug: select_random_item_from_list
Summary: Select Random Item From A Lists in Python. Date: 2016-01-23 12:00
Category: Python
Tags: Basics
Authors: Chris Albon

Interesting in learning more? Check out Fluent Python

Preliminaries


In [1]:
from random import choice

Create List


In [2]:
# Make a list of crew members
crew_members = ['Steve', 'Stacy', 'Miller', 'Chris', 'Bill', 'Jack']

Select Random Item From List


In [3]:
# Choose a random crew member
choice(crew_members)


Out[3]:
'Stacy'