coding random selection from list

Bruce Wolk bawolk at pacbell.net
Tue Feb 29 22:36:24 EST 2000


Actually, the following is even simpler:

import random
random.choice(list)

Cheers, Bruce


doyen at mediaone.net wrote:
> 
> def returnname(list):
>     return list[random.randint(0,(len(list)-1))] # returns a random
> selection from a list
> 
> It seems to work, is it correct and efficient?
> 
> doyen at mediaone.net



More information about the Python-list mailing list