blob: eca8fb3cc3fe11f0c7c215f5119e843bf524a5c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#! /usr/bin/python3
import fileinput
from itertools import chain
c=dict()
for line in fileinput.input():
line=line.rstrip("\r\n")
for rep in ('--',"'s",'.','"','(',')',','):
line=line.replace(rep,' ')
for word in line.split():
c.setdefault(word,0)
c[word] += 1
f=dict()
for w in sorted(c.keys()):
f.setdefault(c[w],list())
f[c[w]].append(w)
for n in sorted(f.keys()):
print(' '.join((list(str(n)) + f[n])))
print('')
|