Hypnos has already answered a very correct solution, so I'm just giving you a more visual way to understand what happened and how to spot those kind of things in the future:
import random
keys = ['1', '2', '3', '4', '5']
a = []
for x in range(10):
random.shuffle(keys)
a.append(keys)
print a
gives:
[['4', '5', '3', '2', '1']]
[['2', '5', '1', '4', '3'], ['2', '5', '1', '4', '3']]
[['2', '5', '4', '1', '3'], ['2', '5', '4', '1', '3'], ['2', '5', '4', '1', '3']]
[['5', '4', '3', '1', '2'], ['5', '4', '3', '1', '2'], ['5', '4', '3', '1', '2'], ['5', '4', '3', '1', '2']]
[['1', '4', '3', '2', '5'], ['1', '4', '3', '2', '5'], ['1', '4', '3', '2', '5'], ['1', '4', '3', '2', '5'], ['1', '4', '3', '2', '5']]
[['2', '3', '4', '1', '5'], ['2', '3', '4', '1', '5'], ['2', '3', '4', '1', '5'], ['2', '3', '4', '1', '5'], ['2', '3', '4', '1', '5'], ['2', '3', '4', '1', '5']]
[['2', '1', '4', '5', '3'], ['2', '1', '4', '5', '3'], ['2', '1', '4', '5', '3'], ['2', '1', '4', '5', '3'], ['2', '1', '4', '5', '3'], ['2', '1', '4', '5', '3'], ['2', '1', '4', '5', '3']]
[['2', '5', '3', '4', '1'], ['2', '5', '3', '4', '1'], ['2', '5', '3', '4', '1'], ['2', '5', '3', '4', '1'], ['2', '5', '3', '4', '1'], ['2', '5', '3', '4', '1'], ['2', '5', '3', '4', '1'], ['2', '5', '3', '4', '1']]
[['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1'], ['3', '5', '2', '4', '1']]
[['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1'], ['4', '2', '3', '5', '1']]
Also, noting that random.shuffle
does not return anything, you can start suspecting that the transformation is done in place.