kevin parks wrote:
Tremendously helpful!!!! One question though. How can i pluck a unique item from my exhaustive list of permutations without repeats making sure that each one is used once? Like filling a bag, shaking it, and then picking from the bag and removing that item from the bag so it isn't used again....

Use random.shuffle() to 'shake' the list. Then use pop() to remove an item:

 >>> import random
 >>> l=range(10)
 >>> random.shuffle(l)
 >>> l
[4, 5, 0, 8, 9, 6, 2, 1, 7, 3]
 >>> l.pop()
3
 >>> l.pop()
7
 >>> l.pop()
1
 >>> l
[4, 5, 0, 8, 9, 6, 2]

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to