#encoding=utf-8
"""
统计名字列表中,各名字的首字母在名字列表中出现的次数
"""
names = ["huhuili","zhangsan","lisi","wangwu","wuermazi"]
def nameFirstLetterData(names):
firstLetterDic = {}
firstLetterList=[]
#将名字的首字母存在一个列表中
for name in names:
firstLetterList.append(name[0])
#将名字首字母和对应的出现次数,存为字典的key和value
for i in firstLetterList:
iData="".join(names).count(i)#计算首字母出现的次数
firstLetterDic[i]=iData
return firstLetterDic
print(nameFirstLetterData(names))