# Starting point for file was prettyCharacterCount.py from Automate the Boring stuff import pprint, sys message = 'It was a a It day it bright cold day in April, and the clocks were striking thirteen.' count = {} for character in message: count.setdefault(character, 0) ## the setdefault line is equivalent to #if character not in count: # count[character] = 0 count[character] = count[character] + 1 #print(character) #sys.exit() pprint.pprint(count)