Possible duplicate:Shuffling a list of objects in python
IF I have a list:
a = ["a", "b", "c", ..., "zzz"]
how can I randomly shuffle its elements to get a list:
b = ["c", "zh", ...]
without consuming a lot of system resources?
import random b = list(a) random.shuffle(b)
random.shuffle() shuffles the sequence in place.
random.shuffle()
Not sure how much resources it consumes, but shuffling in a random module does just that.
import random a = [1,2,3,4,5] random.shuffle(a)