python 返回一个列表中出现次数最多的元素

def max_list(lt):
    temp = 0
    for i in lt:
        if lt.count(i) > temp:
            max_str = i
            temp = lt.count(i)
    return max_str
 
n = [1,2,2,2,3,3,3,3,4,4]
print(max_list(n))

猜你喜欢

转载自blog.csdn.net/qq_42815634/article/details/84137122
今日推荐