Question
IMPORTANT : make sure that you use createAlphabet() as the helper function to generate the alphabet used by the encryption/decryption routines. You should be able
IMPORTANT: make sure that you use createAlphabet() as the helper function to generate the alphabet used by the encryption/decryption routines. You should be able to change the alphabet returned by createAlphabet() and all your other functions should still work correctly.
def createAlphabet():
"""
createAlphabet returns a string that includes
all lowercase letters,
followed by all upper-case letters,
then a space, a comma, a period, a hyphen('-'),
a tilde('~'), and a pound symbol ('#').
NOTE: the order of characters in the alphabet is
very important!
In other words, the string being returned will be
'abcdef...xyzABCDEF...XYZ ,.-~#' (the ellipses ...
hide the alphabet letters)
"""
lc = string.ascii_lowercase
uc = string.ascii_uppercase
return lc + uc + " ,.-~#"
getCharacterBackward(char, key) - return left-shifted character.
After being called, it gets the character to the left of char by moving backward by the specified key positions in the alphabet. For example, if you this function with the parameter c and 2 the result is a and if you call it with a and len(createAlphabet()) the result is a because you are essentially moving over all the characters and so the result is the initial character.
def getCharacterBackward(char, key):
"""
Given a character char, and an integer key,
the function shifts char backward `key` steps.
Return the new character.
If `char` is not a single character, return `None`.
If `key` is not an integer, return -1.
"""
return "stub"
PLEASE ONLY USE FOR OR WHILE LOOP
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started