On Thu, Aug 28, 2008 at 1:33 AM, Alan Gilfoy <[EMAIL PROTECTED]>wrote:
> > The number of items I want from a list is smaller than the population > (number of items) in the list, so it should work. > > In this specific case, I'm asking for one item from a five-item list. Are you sure? change this: for card in random.sample(SpecialA, SA): to this: print "Special: ", SpecialA, "\nSA: ", SA for card in random.sample(SpecialA, SA): then give us the output. I'll bet that your SA value is never reset to 1. > Overall, more code is involved that I think can be represented in a few > cut'n'paste snippets; how would I go about providing the files in question > for interested parties to look at? http://paste.pocoo.org I believe. > > (There's the Python file for my front-end UI code, the Python module file > for my processing function, and the relevant text files) > > Apologizing for message length; I'm just trying to clearly explain the > problem that I want assistance on. You've obviously researched enough to know this: >>> mylist = [1, 2, 3, 4, 5] >>> from random import sample >>> sample(mylist, 3) [2, 1, 4] >>> sample(mylist, 10) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.5/random.py", line 303, in sample raise ValueError, "sample larger than population" ValueError: sample larger than population So give the print statement before your for loop a try and see what you come up with. HTH, Wayne -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor