math.choice attribute error

Remco Gerlich scarblac at pino.selwerd.nl
Tue Mar 27 04:27:00 EST 2001


iddwb <iddwb at imap1.asu.edu> wrote in comp.lang.python:
> 
> from the ref man math.choice says it takes a sequence object and returns a
> random choice. perfect for my needs. the follow happens:
> 
> >>> import math
> >>> list = ['apple', 'orange', 'pear']
> >>> print math.choice(list)
> Traceback ....
> attributerror: choice
> 
> what have I missed?

You're confused, the function is in random, it's random.choice.

-- 
Remco Gerlich



More information about the Python-list mailing list