[Tutor] Challenge

Lucas Prado Melo lukepadawan at gmail.com
Tue Sep 22 14:20:09 CEST 2009


On Tue, Sep 22, 2009 at 9:13 AM, Ali Sina <seena_blk at yahoo.com> wrote:

>  But it prints every number with the string 'heads'. I'm really blank at
> this. It may have something to do with the 'random' module.
>
> You could use the choice function on random.
Given a list, the choice function returns a random element of that list.

from random import choice

print choice([1,2,3,4])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090922/268c46cc/attachment.htm>


More information about the Tutor mailing list