统计不同长度的单词个数,以列表格式输出
import string
a=input()
for i in string.punctuation:
a=a.replace(i,'')
a=a.split(' ')
b=sorted(a,key=len,reverse=False)
c=[len(i) for i in b] #c=[2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 7, 7, 7, 9, 11, 11]
e=[]
for j in c:
if j not in e:
x={j:0}
x[j]=x[j]+1
e.append(x)
print(e)