dimanche 5 juin 2016

python randrange duplicates selection

How can I make sure the value returned is unique each time in python? I am using random.randrange like so -

batter = ("Sammy Slammer","Lonnie Longball","Billy Bomber","Jack Runs","Ricky Redic",)
bnum = random.randrange(0,5)
upnow = batter[bnum]

Which works except I get duplicates often..




Aucun commentaire:

Enregistrer un commentaire