coding random selection from list
Moshe Zadka
moshez at math.huji.ac.il
Wed Mar 1 16:28:34 EST 2000
On Wed, 1 Mar 2000 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?
If you're re-inventing the wheel, try not to make it elliptical...
What's wrong with random.choice?
--
Moshe Zadka <mzadka at geocities.com>.
INTERNET: Learn what you know.
Share what you don't.
More information about the Python-list
mailing list