nums = [5,2,2,3,3,3,4]uniq =sorted(set(nums))print(uniq)dict = {}for i in uniq: dict[i] = nums.count(i) print(dict)
Standard input is empty
[2, 3, 4, 5] {2: 2, 3: 3, 4: 1, 5: 1}
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!