The booster pack generator (my use of random.sample as described in a previous message) is working as intended now.

There was a rather stupid typo in my code that was causing it to go wonky.

Y'all still helped, though. A few people replied, but a bit of advice from: W W <[EMAIL PROTECTED]> pointed me in the right direction.

for card in random.sample(SpecialA, SA):
     print card

he suggested changing to:

print "Special: ", SpecialA, "\nSA: ", SA
for card in random.sample(SpecialA, SA):
     print card

Basically, what my program was doing:

1. Take a textfile, import it/convert it to a list via open("filename.txt).readlines() This list was defined as the variable "SpecialA_list".
2. Feed SpecialA_list, along with some other variables, into my function
3. "SpecialA" variable is set equal to a list consisting of items from "SpecialA_list"
4. Then sample from "SpecialA" & print the results.

Thanks to the print statement that WW suggested, I figured out that the "SpecialA" variable was coming out as an empty list. [error in Step 3 of the above process list, so Step 4 had nothing to sample *from*, thus triggering the traceback]. I found the typo that was causing this, and fixed it. So, the SpecialA variable was set equal to the expected list, so random.sample could sample properly.

Thank you. :)


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to