This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.
# 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()