>>>RandList = np.random.randint(0, 10, (25)) >>>print Counter(RandList)
outputs something like ...
Counter({1: 5, 2: 4, 6: 4, 7: 3, 0: 2, 3: 2, 4: 2, 5: 2, 9: 1})
And with that ...
>>>thislist = Counter(RandList) >>>thislist = thislist.most_common() >>>print thislist [(1, 5), (2, 4), (6, 4), (7, 3), (0, 2), (3, 2), (4, 2), (5, 2), (9, 1)] >>>print thislist[0][0], thislist[0][1] 1 5
source share