Download and save ACT2-6.py
. Open it in IDLE and press F5.
passwordDictionary
. This is a list of the 25 easiest passwords to break in 2011. First, make sure your password doesn't appear on this list: if it does, you should change it after class!printDictionary
with passwordDictionary
as input. Make sure you understand how this function works (it is similar to a function from last class).printDictionary
so it prints the keys in alphabetical order. Use the sort()
function, which is a member function of a list. When you call myList.sort()
, remember that it changes myList
! Try sorting a short list of strings.'george'
(lowercase 'g'!) with the password of your choice as the value. Run printDictionary
again. How is the list sorted?'george'
with one whose key is 'George'
, with the same value. You actually need to do two things to passwordDictionary
to achieve this.addPassword
FunctionThe addPassword
function, as it's currently written, is a bit dangerous. It's fine if I add a new name and password, but I want to be sure that I don't accidentally overwrite an existing name and password.
addPassword
function to print a statement that says 'Warning, overwriting an existing password!'
if you overwrite a password.'Do you really want to overwrite?'
. If the user enters 'y'
or 'yes'
, then overwrite the password. If the user enters 'no'
(or anything else), print 'Returning original dictionary'
and do not modify the dictionary.