Pick random choice from variables

Discussion in 'Python' started by eli m, Feb 10, 2013.

  1. eli m

    eli m Guest

    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.
    eli m, Feb 10, 2013
    #1
    1. Advertising

  2. Joel Goldstick, Feb 10, 2013
    #2
    1. Advertising

  3. eli m

    David Hutto Guest

    On Sun, Feb 10, 2013 at 12:43 PM, Joel Goldstick
    <> wrote:
    >
    >
    >
    > On Sun, Feb 10, 2013 at 12:01 PM, eli m <> 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
    David Hutto, Feb 10, 2013
    #3
  4. eli m

    David Hutto Guest

    The first one I sent directly to you, but it used randint with a list.
    The second should be what you're looking for. If not, then ask a
    little further what you need explained.
    David Hutto, Feb 10, 2013
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mickey Segal
    Replies:
    0
    Views:
    854
    Mickey Segal
    Feb 2, 2004
  2. tom c
    Replies:
    5
    Views:
    378
    tom c
    Nov 1, 2006
  3. miles.jg
    Replies:
    16
    Views:
    851
    Alf P. Steinbach
    Nov 14, 2007
  4. globalrev
    Replies:
    4
    Views:
    739
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,110
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page