[Tutor] Having trouble with a component of the random module
agilfoy at frontiernet.net
Sun Aug 31 18:09:31 CEST 2008
I shouldn't get the same card twice in the same batch, no.
Of course, in separate trials, I may get the same card again.
Basically, I type the names of relevant cards in a list, and proceed
to "tell" my program which list to read, and how many cards to pick
from that list.
Normally, I put each card name in the list only once. But if I type
the same card name twice, the program sees the repetitions as
different entities, and may display both of 'em if the randomness
works out that way.
random.sample I think runs dependent trials (the first pick affects
the odds of the second pick, etc.) - kind of like pulling tickets from
This is as opposed to independent random trials a la dice rolling.
Someone correct me if I'm wrong on this - for this application, I want
Quoting OmerT <Jaggojaggo+Py at gmail.com>:
> I'm unfamiliar with the random.sample function, yet I can't help but wonder:
> Do you ever got the same card twice?
> Is that intentional ?
More information about the Tutor