The encryption works quite well to give "JOP PO". But the decryption of this same "JOP PO" in the decryption part gives "CABBA" instead of "CAB BA". and when I include an elif under the decryption loop it gives me some long stuff like "jjjjjcjjooooaooppppbpp pppppbppoooaoo"
en_dict = {'A' : 'O', 'B' : 'P', 'C' : 'J', 'Z' : 'Z', '0' : 9, '1' : 8, '8' : 1, '9' : 0}
unencrypted_item = "cAb ba"
unencrypted_item = unencrypted_item.upper()
def encrypt(unencrypted_data):
result = ""
for i in unencrypted_item:
if i not in en_dict:
result+=i
else:
result+=en_dict[i]
return result
print(encrypt(unencrypted_item))
encrypted_item = "jop po"
encrypted_item = encrypted_item.upper()
def decrypt(enc_data):
result = ""
for i in encrypted_item:
for n,o in en_dict.items():
if i == o:
result += n
return result
print(decrypt(encrypted_item))`