# ACT 2-5

# Original string, with no punctuation.
origString = 'The cat had a hat The cat sat on the hat'

# Word frequency dictionary.
freqDict = {'the':3,'cat':2,'had':1,'a':1,'hat':2,'sat':1,'on':1}

# Phone number dictionary.
phoneDict = {'Alice':'401-111-1111',
             'Bob':'401-222-2222',
             'Carol':'401-333-3333',
             'Doug':'401-444-4444'}

def printDict(dictionary):
    '''Takes a dictionary as input and prints the key-value pairs. Returns nothing.'''
    keyList = dictionary.keys()
    for key in keyList:
        print 'key:',key,'value:',dictionary[key]
    return

def printList(myList):
    '''Takes a list as input and prints the values.  Returns nothing.'''
    myRange = range(0,len(myList))
    for i in myRange:
        print 'index:',i,'value:',myList[i]
    return

def wordFreq(myString):
    '''Takes a string and returns a dictionary of word frequencies'''
    word_freqs = {}  # Initialize an empty list.
    myList = myString.lower().split()
    for word in myList:
        if not(word_freqs.has_key(word)):
            word_freqs[word] = 1
        else:
            word_freqs[word] = word_freqs[word] + 1
    return word_freqs
