Steven D'Aprano <steve at REMOVEME.cybersource.com.au> writes: > If you want to avoid shuffle, here's an alternative: > > def random_values(n, valuelist=[True, False]): > N = len(valuelist) > for _ in range(N*n): > yield valuelist[random.randrange(0, N)] That is not guaranteed to yield exactly equal numbers of true and false.