字符串-统计个数2

3、统计列表英文字母的单词个数

d = ["a","uhhj","jlkjn",,"jlkjn"]

方法一:

data = list(set(d))
dictcount = {}
for i in data:
dictcount[i]=d.count(i)

方法二:

dictcount = {}
for i in d:
if i not in dictcount.keys():
dictcount[i]=1
else:
dictcount[i] +=1
print(dictcount)
posted @ 2021-11-23 08:50  呆呆蒙蒙  阅读(42)  评论(0编辑  收藏  举报