Pick random choice from variables

David Hutto dwightdhutto at gmail.com
Sun Feb 10 19:01:10 CET 2013

On Sun, Feb 10, 2013 at 12:43 PM, Joel Goldstick
<joel.goldstick at gmail.com> wrote:
> On Sun, Feb 10, 2013 at 12:01 PM, eli m <techgeek201 at gmail.com> wrote:
>> How do i make something with python that will ask the user for input, and
>> then use the random.choice function to select a random choice from what the
>> user entered.
Below is a snippet example:

import random as rand

selection_enter = raw_input("Enter Selection List of Three Items
Seperated By Commas: ")

selection_list = selection_enter.split(",")

print selection_list

rand_choice = rand.choice(selection_list)

print rand_choice

Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com

More information about the Python-list mailing list