txt=input()
for s in ',.\n ':
txt=txt.replace(s,' ')
txt=txt.lower()
list=txt.split()
count=dict()
for i in list:
count[i]=count.get(i,0)+1
sort=sorted(count.items(), key=lambda item:item[1],reverse=True)
print(sort)
txt=input()
for s in ',.\n ':
txt=txt.replace(s,' ')
txt=txt.lower()
list=txt.split()
count=dict()
for i in list:
count[i]=count.get(i,0)+1
sort=sorted(count.items(), key=lambda item:item[1],reverse=True)
print(sort[0][0],sort[0][1])
print(xxx, end=' ')可以实现输出不换行,需要换行的时候直接print()
望采纳, 谢谢!
txt=input()
for s in ',.\n ':
txt=txt.replace(s,' ')
txt=txt.lower()
list=txt.split()
count=dict()
for i in list:
count[i]=count.get(i,0)+1
sort=sorted(count.items(), key=lambda item:item[1],reverse=True)
for i in sort:
for j in i:
print(j,end=' ')