fixing the code

alphabet = ' abcdefghijklmnopqrstuvwxyz'
number = ' 12345678910'
key = 5
#i want c to be checked if it is upper later then deciphered as upper later but if it is lower then it desiphered as lower and if it is number it desiphered as number

def caesar_encrypt(plain_text):
cipher_text = ''

plain_text = plain_text.upper()
for c in plain_text:
index = ALPHABET.find(c)
index = (index+key)%len(ALPHABET)
cipher_text = cipher_text + ALPHABET[index]
return cipher_text

plain_text = plain_text.lower()
for c in plain_text:
index = alphabet.find(c)
index = (index+key)%len(alphabet)
cipher_text = cipher_text + alphabet[index]
return cipher_text

def caesar_decrypt(cipher_text):
plain_text = ''
for c in cipher_text:
index = ALPHABET.find(c)
index = (index-key)%len(ALPHABET)
plain_text = plain_text + ALPHABET[index]

for c in cipher_text:
index = alphabet.find(c)
index = (index-key)%len(alphabet)
plain_text = plain_text + alphabet[index]

return plain_text

if name=="main":
encrypted = caesar_encrypt('This is AN Example')
decrypted = caesar_decrypt(encrypted)

You are viewing a single comment. View All

yes i do not know how to connect these codes together to make the
sentence run prob @MrVoo