Skip to content

Letters in decreasing order of frequency #21410

Answered by Wabri
MaziarAm asked this question in General
Discussion options

You must be logged in to vote

I dont think there is a real reason. I think the only one reason that i have in mind is maybe to split the tasks of words and twords. The output of letters with twords and words are the same (I didnt tried it but I’m sure of that). To test the output of words and twords you can do something like this:

fname = input("Enter a file name: ")
if len(fname) < 1 : fname = "romeo.txt"
try :
    fhand = open(fname)
except :
    print("Enter a proper file name",fname )
    quit()

#read the file into a big string
words = fhand.read()

#lower the string
words = words.lower()

letters = list()
for i in words :
if i.isalpha() == True :
letters.append(i)

twords = tuple(words)

letters2 = list()
for i in tw…

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants