统计字母在字符串中出现的字数(不重复统计)

  • 根据每个字母在字符串s中首次出现的次序依次打印每个字母及其出现的次数。
s=input()
a=[]
for i in s:
    if i not in a:
        a.append(i)
        print(i,s.count(i))