import random def pieces(): while True: bag = ['I', 'O', 'T', 'S', 'Z', 'J', 'L'] random.shuffle(bag) while bag: yield bag.pop() gen = pieces() print ', '.join(gen.next() for _ in xrange(21))
Standard input is empty
S, Z, T, O, L, J, I, O, J, T, Z, S, L, I, L, Z, T, S, O, J, I
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!