Created
October 27, 2022 04:55
-
-
Save RaMSFT/c46f08da0d7b57347523963942738c1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def decrypt_shift_right(decode_str): | |
"""Decode the given string (a step up the alphabest) | |
a -> c | |
b -> d | |
... | |
k -> m | |
o -> q | |
e -> g | |
.. | |
z -> b | |
""" | |
new_string = '' | |
for decode_char in decode_str: | |
if decode_char.isalpha(): | |
ascii_value = ord(decode_char) | |
new_ascii = (ascii_value - 26 + 2) if (ascii_value >= 121) else (ascii_value + 2) | |
#print(new_ascii) | |
new_char = chr(new_ascii) | |
else: | |
new_char = decode_char | |
new_string = new_string + new_char | |
return new_string | |
print(decrypt_shift_right("fcjjm ucjamkc rm nwrfml..!!")) | |
print(decrypt_shift_right("g yk pykcqf...")) | |
print(decrypt_shift_right("wms'pc pcybgle gl kcbgsk")) | |
print(decrypt_shift_right("njcyqc qszqapgzc rm kw qrmpgcq")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment