Skip to content

Instantly share code, notes, and snippets.

@RaMSFT
Created October 27, 2022 04:55
Show Gist options
  • Save RaMSFT/c46f08da0d7b57347523963942738c1d to your computer and use it in GitHub Desktop.
Save RaMSFT/c46f08da0d7b57347523963942738c1d to your computer and use it in GitHub Desktop.
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