Python取出数组中重复次数最多的数
作者:互联网
def max_list(lt): temp = 0 for i in lt: if lt.count(i) > temp: max_ele = i temp = lt.count(i) return "重复次数最多元素为%s,重复次数为%d次" % (max_ele, temp) n = ['a','b','a','c','d','a'] print(max_list(n)) 重复次数最多元素为a,重复次数为3次
标签:count,temp,Python,max,次数,lt,数组,重复 来源: https://www.cnblogs.com/lucktomato/p/16323538.html