You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
2 years ago | |
---|---|---|
README.md | 2 years ago |
README.md
SaaS1
import string def countChar(): filename = input() infile=open(filename,'r') chCounts={} for line in infile: processLine(line.lower(),chCounts) infile.close() lst=list(chCounts.items()) lst=[(y,x) for (x,y) in lst] lst.sort(reverse=True) for i in range(10): print(lst[i][1],':',lst[i][0]) return chCounts def processLine(line,chCounts): for ch in line: if ch in string.punctuation+string.whitespace: line=line.replace(ch,' ') for ch in line.split(): chCounts[ch] = chCounts.get(ch,0)+1 chCounts=countChar()