# ACT 2-6

# from http://finance.yahoo.com/news/25-worst-passwords-2011-revealed-202955980.html
passwordDictionary = {'Alice':'password',
                      'Bob': '123456',
                      'Carol':'12345678',
                      'Deb':'qwerty',
                      'Emma':'abc123',
                      'Florence':'letmein',
                      'Gary':'trustno1',
                      'Hillary':'dragon',
                      'Ingrid':'baseball',
                      'Jeremy':'111111',
                      'Kyle':'iloveyou',
                      'Lou':'master',
                      'Mary':'sunshine',
                      'Ned':'ashley',
                      'Owen':'bailey',
                      'Pat':'passw0rd',
                      'Quintin':'shadow',
                      'Ryan':'123123',
                      'Sandra':'654321',
                      'Trevor':'superman',
                      'Uma':'qazwsx',
                      'Valerie':'michael',
                      'Wilbur':'football'}

# Task 1
def printDictionary(dictionary):
    '''Prints the dictionary key-value pairs from a dictionary.'''
    keyList = dictionary.keys();
    keyList.sort();
    for key in keyList:
        print key,' -> ',dictionary[key]
    return

# Task 2
def echo():
    myInput = raw_input('write something and hit Enter: ')
    print 'You wrote:',myInput
    return

def addPassword(dictionary,key,value):
    '''Adds the (key,value) pair to the dictionary and returns the new dictionary'''
    if key in dictionary:
        myInput = raw_input('Warning! '+str(key)+' is already a key. Proceed? ')
        if (myInput == 'y') or (myInput == 'yes'):
            myInput = raw_input('Original Password: ')
            if(myInput == dictionary[key]):
                print 'Changing Password.'
                dictionary[key] = value
            else:
                print 'Incorrect Password.'
        else:
            print 'Not modifying the dictionary.'
    return dictionary
