标签:次数 ict ted div print class set school let
pyschools 上面的题目:给定一个单词,输出字母及字母出现次数
python真是方便,可以一行代码搞定
def countLetters(word): return dict(sorted([(l,word.count(l)) for l in set(word)])) print(countLetters(‘google‘)) {‘e‘: 1, ‘g‘: 2, ‘l‘: 1, ‘o‘: 2}
标签:次数 ict ted div print class set school let
原文地址:https://www.cnblogs.com/yongestcat/p/13433463.html