Trying to use sets for random selection, but the pop() method returns items in order

Paul Rubin http
Wed Jul 1 20:49:21 EDT 2009


Carl Banks <pavlovevidence at gmail.com> writes:
> Instead, call random.shuffle() on the list, and iterate through that
> to get the elements in random order.

It's better to use random.sample() than random.shuffle().



More information about the Python-list mailing list