Created
April 13, 2017 10:09
-
-
Save daylanKifky/9e6c058258541a2987f1867c967b5334 to your computer and use it in GitHub Desktop.
distribute list shuffle python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [a for a in range(20)] | |
from random import shuffle | |
shuffle(a) | |
print a | |
#[13, 2, 4, 5, 10, 3, 0, 9, 14, 12, 8, 11, 7, 6, 15, 16, 17, 18, 1, 19] | |
lista = [[],[],[]] | |
for i,val in enumerate(a): | |
lista[i%3].append(val) | |
print lista | |
#[[13, 5, 0, 12, 7, 16, 1], [2, 10, 9, 8, 6, 17, 19], [4, 3, 14, 11, 15, 18]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment