字典计算列表中的数字出现次数

a = [1, 2, 3, 1, 1, 3, 6, 9, 6, 9, 9, 1, 2, 2, 2, 6, 6, 6]
b = {}
for j in c:
    if j in b.keys():
        b[j] = b[j] + 1
    else:
        b[j] = 1
for k in b.keys():
    print(“值”, k, "&", “出现次数”, b[k])
    原文作者:yjinyyzyq
    原文地址: https://blog.csdn.net/yjinyyzyq/article/details/81567105
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞