Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38585 > unrolled thread

Pick random choice from variables

Started byeli m <techgeek201@gmail.com>
First post2013-02-10 09:01 -0800
Last post2013-02-10 13:03 -0500
Articles 4 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Pick random choice from variables eli m <techgeek201@gmail.com> - 2013-02-10 09:01 -0800
    Re: Pick random choice from variables Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-10 12:43 -0500
    Re: Pick random choice from variables David Hutto <dwightdhutto@gmail.com> - 2013-02-10 13:01 -0500
    Re: Pick random choice from variables David Hutto <dwightdhutto@gmail.com> - 2013-02-10 13:03 -0500

#38585 — Pick random choice from variables

Fromeli m <techgeek201@gmail.com>
Date2013-02-10 09:01 -0800
SubjectPick random choice from variables
Message-ID<2b79c66b-0750-46c5-a436-edf369747af2@googlegroups.com>
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.

[toc] | [next] | [standalone]


#38588

FromJoel Goldstick <joel.goldstick@gmail.com>
Date2013-02-10 12:43 -0500
Message-ID<mailman.1591.1360518212.2939.python-list@python.org>
In reply to#38585

[Multipart message — attachments visible in raw view] — view raw

On Sun, Feb 10, 2013 at 12:01 PM, eli m <techgeek201@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.
>
l = [1,2,3] # or any list

r = random.choice(l)

> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com

[toc] | [prev] | [next] | [standalone]


#38589

FromDavid Hutto <dwightdhutto@gmail.com>
Date2013-02-10 13:01 -0500
Message-ID<mailman.1592.1360519279.2939.python-list@python.org>
In reply to#38585
On Sun, Feb 10, 2013 at 12:43 PM, Joel Goldstick
<joel.goldstick@gmail.com> wrote:
>
>
>
> On Sun, Feb 10, 2013 at 12:01 PM, eli m <techgeek201@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

[toc] | [prev] | [next] | [standalone]


#38590

FromDavid Hutto <dwightdhutto@gmail.com>
Date2013-02-10 13:03 -0500
Message-ID<mailman.1593.1360519442.2939.python-list@python.org>
In reply to#38585
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.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web