Here was my attempt at finding the most frequent integers in a list, I feel like there are better ways to do this and I spent a great deal of time coming up with this solution, so please point me in the correct direction!
''' Created on Jan 27, 2018 Problem statement: Find the most frequently occuring integer in a list and its occurence; input: 1 1 2 3 2 1 2 output: [(1,3), (2, 3)] @author: Anonymous3.1415 ''' from collections import Counter def integer_frequency(int_list): int_freq = Counter() for i in int_list: int_freq[i] += 1 cnt = 0 values = sorted(int_freq.values()) values.reverse() for x in values: if x == values[0]: cnt += 1 else: break return int_freq.most_common(cnt) int_list = list(map(int, raw_input().strip().split(' '))) most_frequent = integer_frequency(int_list) print(most_frequent)