# Coded Correspondence (Step 1 & Step 2 Solutions)

Hello, I’ve finished step 1 and step 2 of the Coded Correspondence project and thought I’d like to get some feedback on my solutions. I feel like there’s a much simple approach to tackle these tasks and my solution, even though it works, seems like it’s repeated.

STEP 1: Decrypt

``````def encrypted_message():
cipher_text = "xuo jxuhu! jxyi yi qd unqcfbu ev q squiqh syfxuh. muhu oek qrbu je tusetu yj? y xefu ie! iudt cu q cuiiqwu rqsa myjx jxu iqcu evviuj!"
return cipher_text

def translate_message():

secret_code = encrypted_message()

offset = 10

decrypted_message = ""

for char in secret_code:
if char.isalpha():
ord_num = ord(char) + offset

if ord_num > ord('z'):
ord_num -= 26

decrypted_message += chr(ord_num)
else:
decrypted_message += char

return decrypted_message

print(translate_message())
``````

STEP 2: ENCRYPT

``````def encrypt_message():

plain_text = uncoded_message()

offset = -10

decrypted_message = ""

for char in plain_text:
if char.isalpha():
ord_num = ord(char) + offset

if ord_num < ord('a'):
ord_num += 26

decrypted_message += chr(ord_num)
else:
decrypted_message += char

return decrypted_message
``````

Not many changes in step 1 and step 2, except that it won’t account for capital letters. My solution to that is this:

``````if char.islower():
if ord_num > ord('z'):
ord_num -= 26
elif ord_num < ord('a'):
ord_num += 26
elif char.isupper():
if ord_num > ord('Z'):
ord_num -= 26
elif ord_num < ord('A'):
ord_num += 26
``````

it’s not pretty, but it works. It’d be wonderful to know a much simpler way to do that. Thank you.