Aug-07-2018, 09:40 PM
@ichabod801 and @buran - thank you once again for taking the time sharing your ideas!
I managed to restructure my code and it works fine but my next question is how can I make the output like a table as shown in the screenshot here?
[Image: 070818_zpshfys00vk.png]
==============================================================================
I managed to restructure my code and it works fine but my next question is how can I make the output like a table as shown in the screenshot here?
[Image: 070818_zpshfys00vk.png]
==============================================================================
file = open("alice_in_wonderland.txt", "r", errors ='ignore') # open file charcount = {} #dictionary to hold char counts validchars = "abcdefghijklmnopqrstuvwxyz" # only these counted print(": Letter : Frequency :") for i in range(97,123): # lowercase range c = (chr(i)) # the chars a-z charcount[c] = 0 # initialize count for line in file: words = line.split(" ") # line into words for word in words: # words into chars chars = list(word) #convert word into a char list for c in chars: # process chars if c.isalpha(): # only alpha allowd if c.isupper(): c = c.lower() # if char is upper convert to lower if c in validchars: # if in valid char set charcount[c] += 1 # increment count print(charcount) # print list file.close() # close fileThank you in advance!
Blockchain Visionary & Aspiring Encipher/Software Developer
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube