统计输入的字符串中每个字母('a'~'z', 'A'~'Z')出现的次数(其他字符不统计)。统计结果存储在字典中。
输入输出示例
输入: hello 输出: {'h': 1, 'e': 1, 'l': 2, 'o': 1}
此代码适合进一步练习字典的使用。
a=input()
d1={}
b=a.replace('_','')
d=b.replace('.','')
for i in d:
c=0
for j in d:
if i ==j:
c=c+1
d1[i]=c
print(d1)