不多说,直接贴了:

import  random
from collections import Counter
# what will i do:找到十个随机数之中的众数
# 统计数字的转换为 数字 和 出现次数 的格式
# 统计次数最多的
# 根据次数找下标 (先试试枚举)
# 找到它
# def mn(xl,bl):  #以字典形式
#     pass
#     for i in xl:
#          bl[i]=bl.get(i,0)+1
#     return bl
al=[random.randint(1,20) for i in range(10)]
# bl={}
print("数据是:",al)
print('*'*50)
c=Counter(al)


dd=c.most_common(len(al)) #转为列表

print("转换后:",dd)
#把出现次数最大的都找到 要下标和个数
hh=[t for i,t in dd]
if(len(hh)==len(al)):
    print("对不起,你找不到众数")
else:
    nmax =hh.count(max(hh))#最大次数的个数
    print("maxnum:",nmax,"---------------------------")
    ii=c.most_common(nmax)
    print("找到众数{0}个它们是:".format(nmax))
    for i in ii:
         print(i[0],end=' ')

结果为:

数据是: [10, 2, 7, 19, 4, 1, 5, 16, 7, 20]
**************************************************
转换后: [(7, 2), (10, 1), (2, 1), (19, 1), (4, 1), (1, 1), (5, 1), (16, 1), (20, 1)]
maxnum: 1 ---------------------------
找到众数1个它们是:
7

补充:个人还有点小想法,把字典values的值 跟下标 枚举出来 统计次数
接下来,根据下标,输出keys

个人想法,欢迎指教