On 18/10/06, Terry Carroll <[EMAIL PROTECTED]> wrote:
> On Sat, 14 Oct 2006, John Fouhy wrote:
>
> > >From the python_dev LiveJournal community ---
> >
> > Predict the outcome of the following code:
> >
> > ##
> > from random import *
> > seed()
> > [choice(dict((x+1,0) for x in range(1000))) for x in range(693)][0]
> > ##
>
> On ActivePython 2.4.3:
>
> >>> from random import *
> >>> seed()
> >>> [choice(dict((x+1,0) for x in range(1000))) for x in range(693)][0]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "C:\Python24\Lib\random.py", line 249, in choice
>     return seq[int(self.random() * len(seq))]  # raises IndexError if seq is 
> empty
> KeyError: 0
> >>>

Does that always happen?

-- 
John.
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to