Question: # 3. Implement sub_decrypt(password) def sub_decrypt(password, ciphertext): Decrypt ciphertext using the substitution cipher. If a character is not in the key, the character remains unchanged.
# 3. Implement sub_decrypt(password) def sub_decrypt(password, ciphertext): """Decrypt ciphertext using the substitution cipher. If a character is not in the key, the character remains unchanged. The ciphertext should be normalized to all lowercase letters.
s = 'le tge svhpbkeges. cyee ti bape.' sub_decrypt(s) # --> we are discovered. flee at once.
:param password: the password used to generate a key :type password: str :param ciphertext: the text to be decrypted :type ciphertext: str :return: the plain text that results from decrypting the ciphertext :rtype: str """ # implement this function! return '' key = gen_key(password) alpha = gen_consecutive_chars() ciphertext = ciphertext.lower() rstr = '' for i in ciphertext: if i in key: rstr += alpha[key.index(i)] else: rstr += i return rstr
I am getting an invalid syntax error on my else:
statement how do i fix this issue?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
