''' File: letterCount.py Author: CS 1510 Description: Prints a table of the counts of each letter in a string. ''' #Function letterCount #Inputs: inputStr (string) #Outputs: None #Description: Prints a table of the letters of the alphabet (in # alphabetical order) together with the number of times each letter # occurs in inputStr. def letterCount(inputStr): letters="abcdefghijklmnopqrstuvwxyz" #Let's make our input string lowercase lowerStr = inputStr.lower() #create the letter dictionary letterDict={} #populate the dictionary with letters, each with count of 0 for char in letters: letterDict[char]=0 #Go through our sentence, adding one to our dictionary for #each letter we find for char in inputStr: if char in letters: letterDict[char] +=1 #Print the dictionary #How come for key in letterDict will print out in random order? for char in letters: print(char, letterDict[char]) return None