filtering random values (sieves?)

kevin parks kp87 at lycos.com
Wed Feb 13 11:27:50 EST 2002


I am not sure I am even using the right terminology here, but I
looking for a way to filter random values. Let's say that I am using
random and randrange to generate values from 0-11, but i only want to
accept values 1, 3, 5, 7, 11, (that is just off the top of my head,
could be anything) how would i filter out values that i don't want?
The only way i can think of is just asking the program to choose
again, but that may not be the best way since, at least
hypothetically, you could keep choosing values that are rejected...

Any help would be appreciated.

-kevin



More information about the Python-list mailing list