Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # listbycount.py
- mylist = [1, 1, 6, 1, 3, 3, 4, 4, 4, 4, 5, 2, 2, 2, 2]
- mydict = {}
- for i in set(mylist):
- mydict[i] = mylist.count(i)
- t = sorted(mydict.items(), key=lambda value: value[1], reverse=True)
- print t
Add Comment
Please, Sign In to add comment