解题思路:
把单词后面跟的','和'.'处理一下,然后用format格式输出即可。
注意事项:
参考代码:
def f(): words = [] maxlen = 0 s = [word for word in input().split()] for i in range(len(s)): if '.' in s[i] or ',' in s[i]: s[i] = s[i][:len(s[i])-1].upper() else: s[i] = s[i].upper() if s[i] not in words: words.append(s[i]) if len(s[i]) > maxlen: maxlen = len(s[i]) for word in words: print('{:>{}}:'.format(word,maxlen)+'*'*s.count(word)+'{}'.format(s.count(word))) if __name__ == '__main__': f()
0.0分
0 人评分