眾數是集合中重複次數最多的值。
輸入資料可能出現最多次 不只一組
輸入
12
2 4 2 3 2 5 3 7 2 3 4 3
輸出
2 4
3 4
=========================================
ANS
import collections
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
n=input()
a=list(map(int,input().split()))
print(a)
b=collections.Counter(a)
print(b)
m = 0
for k, v in b.items():
if (v >=m):
m=v
print("max", m)
for k, v in b.items():
if (v==m):
print(k,v)
=====================================
第二個ANS
#本解法是使用 d.items() 取KEY VALUE
#
#student = {'name': 'Alice', 'age': 20, 'grade': 'A'}
#major = student.get('major', '未指定專業')
#print(major) # 輸出:未指定專業
#
l1=int(input())
l2=sorted(list(map(int,input().split())))
d=dict()
for i in l2:
d[i]=d.get(i,0)+1
maxv=max(d.values())
for x, y in d.items():
if (y==maxv):
print(x, y)