import string bs=input() for i in string.punctuation: bs = bs.replace(i,' ') Ls=bs.split() #print(Ls) d={} for word in Ls: w=len(word) if w in d: d[w]+=1 else: d[w]=1 Lresult=list(d.items()) Lresult.sort(key=lambda x:x[0]) print(Lresult)