math.choice attribute error
Sean 'Shaleh' Perry
shaleh at valinux.com
Mon Mar 26 20:43:39 EST 2001
On 27-Mar-2001 iddwb wrote:
>
> 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
>
I know random does:
>>> import random
>>> l = [1, 2, 3]
>>> random.choice(l)
2
More information about the Python-list
mailing list