In data list enumerate randint 10 for in xrange 100 In groups In for i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
In [6]: data = list(enumerate(randint(1,10) for i in xrange(100)))
In [7]: groups = {}
In [8]: for id, count in data:
...: groups.setdefault(count, []).append(id)
...:
In [9]: groups
Out[9]:
{1: [15, 29, 46, 61, 73, 79, 89, 93, 95],
2: [12, 25, 28, 30, 32, 39, 41, 59, 67, 84, 86, 98],
3: [19, 31, 33, 43, 49, 56, 70, 97],
4: [3, 22, 37, 48, 52, 80],
5: [0, 2, 8, 13, 14, 17, 42, 45, 55, 64, 68, 74, 85, 87, 94],
6: [16, 20, 34, 44, 57, 77, 90, 91],
7: [40, 54, 65, 75, 78, 88],
8: [5, 6, 7, 10, 35, 50, 58, 66, 81, 96],
9: [11, 23, 26, 47, 51, 53, 63, 69, 72, 82, 99],
10: [1, 4, 9, 18, 21, 24, 27, 36, 38, 60, 62, 71, 76, 83, 92]}