Passwordify
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
As an intern for Computer Securities (CS), you are assigned the task of making the company's employee passwords more secure. Your manager Larry instructs you to implement the following algorithm to transform the old string passwords into new strings:
- Any occurence of
'o'
in the old password should become'0'
. - Any occurence of
'e'
should become'3'
- Any occurence of
'i'
should become'!'
You should not replace any other characters (even, for example, uppercase 'O'
, 'E'
, or 'I'
characters).1
def strengthen_password(password):
"""
Creates a new password according to the following rules:
- o becomes 0
- e -> 3
- i -> !
Inputs:
password (str) - current password
Returns:
A string representing the new password.
"""
pass # your code here
if __name__ == "__main__":
# Local testing -- feel free to add your own tests as well!
print(f"Got {strengthen_password('iLoveDogs123')=}, Expected='!L0v3D0gs123'")
Once you've tested your code by hand, upload your file for testing:
Note: In the process of writing and debugging your program, you may wish to add additional print
statements. That's fine! Just make sure to put them in the __main__
block (or remove them before you submit), or else our checker will get confused.
Next Exercise: Compound Interest
Footnotes
1Disclaimer: this algorithm is far from sufficient to create safe passwords! Wikipedia gives good guidelines to protect yourself.