Most frequent integer in a list 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)
You could use itertools.takewhile to keep on taking tuples until they are not the same count anymore:

from collections import Counter
from itertools import takewhile

def integer_frequency(integers):
    int_freq = Counter(integers)
    most_common = int_freq.most_common(1)[0]
    return list(takewhile(lambda x: x[1] == most_common[1],
                          int_freq.most_common()))


I also renamed your integer_list to integers, because it can be any iterable of integers.

Alternatively, you could use itertools.groupby to group the tuples by their frequency and return the group with the highest frequency, as @Gareth Reese has suggested in the comments:

from collections import Counter
from itertools import groupby

def integer_frequency(integers):
    return list(next(groupby(Counter(integers).most_common(),
                             key=lambda x: x[1]))[1])


This approach is consistently faster (by a small amount):



However, both beat your algorithm by quite a lot: