def repeat_nums(arrays):
"""
list.count(obj):返回元素在列表中出现的次数
:param arrays: 输入一个列表
:return:数组里重复次数最多的值
"""
if (type(arrays)) != list:
print("输入类型错误,请输入一个列表类型数据")
else:
if (len(arrays)) == 0:
print("该列表是为空")
else:
dict_num = {}
nums = 0 #列表里重复次数最多的值
element = 0 #返回列表里重复次数最多的元素
for item in arrays:
if item not in dict_num.keys():
dict_num[item] = arrays.count(item)
if dict_num[item] >= nums:
nums = dict_num[item]
element = item
print(dict_num, nums, element)
return dict_num, nums, element
if __name__ == '__main__':
repeat_nums([1,2,3,1,2,4,5,6,1,1,1,2,2])