here is my code:
import random
from random import shuffle
a = ['a','b','c','d']
b = ['a','b','c','d']
c = ['w','x','y','z']
d = ['w','x','y','z']
indices = random.sample(range(len(a)), len(a))
a = map(a.__getitem__, indices)
b = map(b.__getitem__, indices)
shuffle(c)
shuffle(d)
print a,b,c,d
What this code does is it shuffles a and b in the same order, and shuffles c and d in their own order. What I am trying to do now is making two longer lists composed of a and c, and b and d, and put them in a randomized order. What I want though is for a and b stay the same order across lists. Is there any way to do this? Any help will be greatly appreciated. :)
Edit:
I would like the output to look something like this, where lists a&b correspond and c&d are just randomized independently.
['d','x','w','b','a','y','c','z']
['d','z','y','b','a','x','c','w']
Aucun commentaire:
Enregistrer un commentaire